You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by kate <li...@livejournal.com> on 2006/01/28 08:45:27 UTC

index concurrency & result order

hi list,

i'm trying to use Lucene (1.4.3) to replace an existing MySQL search system.  
so far, this is working great, but i have a couple of questions.

firstly, when my index updater is (re)indexing a lot of documents at once, i 
often get errors like 
"FileNotFoundException: /usr/local/searchindex/index/index/_107ei.fnm (No 
such file or directory)" from clients trying to search the index.  i'm 
assuming this is because the reader is trying to read files while the 
writer is changing them; but i was under the impression Lucene created 
read/write locks to prevent this happening.  do i need to do something 
special to make the locks work for reading as well?  or should i handle 
this some other way? (the index is accessed as single writer/multiple 
reader).

secondly, the existing MySQL-based search returns documents in alphabetical 
order by title, instead of by relevance.  i'd like to replicate this 
behaviour for the (few) people who prefer the existing system; however, i'm 
not sure how to do it efficiently.  i see i can pass my own HitCollector to 
search(), and then retrieve the document's title and sort by title myself.  
however, HitCollector.collect() says "For good search performance, 
implementations of this method should not call Searchable.doc(int) or 
IndexReader.document(int) on every document number encountered."

so - is there another way to affect the order?  it certainly does seem 
inefficient to retrieve the entire document, when i only need the title 
field from it.

thanks,
k.

Re: index concurrency & result order

Posted by kate <li...@livejournal.com>.
Chris Hostetter:
> You don't need to use a HitCollector just to sort by a field, take a
> look at the Search.search(Query,Sort) method instead.

thanks - this is exactly what i needed.

k.

Re: index concurrency & result order

Posted by Chris Hostetter <ho...@fucit.org>.
: secondly, the existing MySQL-based search returns documents in alphabetical
: order by title, instead of by relevance.  i'd like to replicate this
: behaviour for the (few) people who prefer the existing system; however, i'm
: not sure how to do it efficiently.  i see i can pass my own HitCollector to

You don't need to use a HitCollector just to sort by a field, take a look
at the Search.search(Query,Sort) method instead.

Pay special attention to the javadocs for the Sort class.  You can only
sort of fields which are indexed in a specific way...

http://lucene.apache.org/java/docs/api/org/apache/lucene/search/Searcher.html#search(org.apache.lucene.search.Query,
org.apache.lucene.search.Sort)

http://lucene.apache.org/java/docs/api/org/apache/lucene/search/Sort.html



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org