Mailing List
Home
Forum Home
Maven - Project building tool
Axis - Java SOAP implementation
Cocoon - MVC web framework based on XML/XSL
Lucene - Full-featured text search engine APIs
Log4J - A log library
Fop - Create PDF, PCL, PS, SVG, XML driven by XSL formatting objects.
POI - Java Excel, Word and other Microsoft Office files manipulating library
Oracle database error code ...
Subjects
log4j warning: No appenders could be found
java security AccessControlException: access denied (java io FilePermission clie
java lang InstantiationException: org apache tools ant Main
Apache Axis Tutorial
Struts <logic iterate >
log4j properties How to parse outpu to multiple files
configuring log4j with BEA Weblogic 8 1
How to use XSL FOP Java together
JSP precompile
Servlet File Download dialog problem (IE6,Adobe 6 0)
Proposal: Adding jar manifest classpath in jar and war plugins
Unsupported major minor version 48 0 problem while running the an
   telope task
java security AccessControlException: access denied (java io FilePermission
axis wsdl2java Ant Task usage
net sf hibernate MappingException: Error reading resource: test/User hbm xml
Building EAR ANT Script for websphere 5 0
CREATING WAR Files
jsp data into Excel
Classpath problem
Jboss 3 2 3+ vs Tomcat Axis Question
RE: How to include jars and add them into the MANIFEST MF/Class Path
attribute
Printing problem
InstantiationException
Couldn 't find trusted certificate
Please : How can one install ant 1 6 0 under Eclipse 2 1 ?
Excel: Too many different cell formats
Running junit tests fails
XDoclet, Struts and Maven: Where to start? SOLUTION
1 3 final: now giving me java io FileNotFoundException (Too many
open files)
AXIS: tomcat timeout ?
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
best way of reusing IndexSearcher objects

best way of reusing IndexSearcher objects

2003-12-18       - By Doug Cutting

 Back
Reply:     1     2     3     4     5     6     7     8     9     10  

Dror Matalon wrote:
> There are two issues:
> 1. Having new searches start using the new index only when it's ready,
> not in a "half baked" state, which means that you have to synchronize
> the switch from the old index to the new one.

That's true.  If you're doing updates (as opposed to just additions)
then you probably want to do something like:
  1. keep a single open IndexReader used by all searches
  2. Every few minutes, process updates as follows:
    a. open a second IndexReader
    b. delete all documents that will be updated
    c. close this IndexReader, to flush deletions
    d. open an IndexWriter
    e. add all documents that are updated
    f. close the IndexReader
    g. replace the IndexReader used for searches (1, above)

> 2. It's not trivial to figure out when it's safe to discard the old
> index; all existing searches are done with it.
>
> To make things more complicated, the Hits object is dependent on your
> IndexSearcher object, so if you have Hits objects in use you probably
> can't  close your IndexSearcher.
>
> Is this a correct analysis or is there an obvious strategy to work
> around this issue?

Right, you cannot safely close the IndexReader that's being used for
searching.  Rather, just drop it on the floor and let it get garbage
collected.  Its files will be closed when this happens.  Provided you're
not updating more frequently than the garbage collector runs, you should
only ever have two IndexReaders open and shouldn't run into file handle
issues.

Doug


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: lucene-user-unsubscribe@(protected)
For additional commands, e-mail: lucene-user-help@(protected)




Earn $52 per hosting referral at Lunarpages.