Hi
Thanks for your reply. I originally explicitly closed the
multisearcher but this caused problem in that first search would work
and then subsequent searches would cause an
IndexReaderClosedException. I sent an email to the mailing group on
what the best practice is on whether to close the multi searcher or
leave it open.
I couldn't see in the dogs how to re open. Would it be possible to
get some advice on how to do this.
Thanks again for your help.
On 19 Jan 2009, at 23:23, Greg Shackles <gshack...@gmail.com> wrote:
I just quickly skimmed the code since I don't have much time right
now but
it looks like you are keeping an array of IndexSearchers open that you
re-use in this search function, right? If that's the case, you need
to tell
those IndexSearchers to re-open the indexes because they have
changed since
they were first opened. That should solve your problem.
- Greg
On Mon, Jan 19, 2009 at 4:45 PM, Amin Mohammed-Coleman <ami...@gmail.com
>wrote:
I make a call to my search class which looks like this:
public Summary[] search(SearchRequest searchRequest) {
List<Summary> summaryList = new ArrayList<Summary>();
StopWatch stopWatch = new StopWatch("searchStopWatch");
stopWatch.start();
MultiSearcher multiSearcher = null;
try {
multiSearcher = new
MultiSearcher(searchers.toArray(new IndexSearcher[] {}));
QueryParser queryParser = new
MultiFieldQueryParser(FieldNameEnum.fieldNameDescriptions(),
analyzer);
Query query =
queryParser.parse(searchRequest.getSearchTerm());
//TODO: Sort and Filters
TopDocs topDocs = multiSearcher.search(query,
100);
ScoreDoc[] scoreDocs = topDocs.scoreDocs;
LOGGER.debug("total number of hits for [" +
query.toString() + " ] = " +topDocs.totalHits);
for (ScoreDoc scoreDoc : scoreDocs) {
final Document doc =
multiSearcher.doc(scoreDoc.doc);
float score = scoreDoc.score;
final BaseDocument baseDocument = new
BaseDocument(doc, score);
Summary documentSummary = new
DocumentSummaryImpl(baseDocument);
summaryList.add(documentSummary);
}
} catch (Exception e) {
throw new IllegalStateException(e);
}
stopWatch.stop();
LOGGER.debug("total time taken for seach: " +
stopWatch.getTotalTimeMillis() + " ms");
return summaryList.toArray(new Summary[] {});
}
Do I need to do this explicitly?
Cheers
Amin
On 19 Jan 2009, at 20:48, Greg Shackles wrote:
After you make the commit to the index, are you reloading the index
in the
searchers?
- Greg
On Mon, Jan 19, 2009 at 3:29 PM, Amin Mohammed-Coleman <ami...@gmail.com
wrote:
Hi
I have recently worked on developing an application which allows
you to
upload a file (which is indexed so you can search later). I have
numerous
tests to show that you can index and search documents (in some
instances
within the same test), however when I perform the operation in
the site:
1) Upload File and Index
2) Search
I don't get any hits. When I restart the application then if I
make
another search I can find the results. It seems as though
indexes aren't
being committed when I do the initial upload. This is strange. I
explicitly call commit in my code when I upload the file. Has
anyone
experienced this before?
Any help would be appreciated.
Kind Regards
Amin
---
------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org