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 Ravi <ra...@siti.com> on 2006/01/20 13:30:24 UTC

: Creating searcher object for read opertions:

 

 

 

Hi ,

 

I want to create searcher object for only read operation. I read that we can
open any number of read only connections  and we can work with them .

 

But when they can be closed ,if we continually opens ,is there any problem
with that.. I want to use single searcher object which can solve this
problem. I want to open the searcher object when the application started and
I want to close the searcher object when the application closed. But If I do
like that, I am able to see only those records which are existed in the
index dir when I created searcher object . whenever I add new thing it is
not reflecting until unless I restart the application. I don't want to
restart the application each time when the index modified . Please tell me
the solution how to solve this problem or we should use like that .. I am
giving the code which is repeating every time I use searching  even though
the index does not modified. 

 

 

 

 

 

try{

              String strIndexPath                 =    "D:\\ravi\\Index";

                               try {

                    objFSDirectory              =
FSDirectory.getDirectory(new File(strIndexPath), false);

                    boolean bIsLocked           =
IndexReader.isLocked(strIndexPath);

                    System.out.println("-------------> Is
Locked="+bIsLocked);

                    if (bIsLocked) {

                        synchronized(objFSDirectory)    {

                            IndexReader.unlock(objFSDirectory);

                        }

                    }

                    reader      =   IndexReader.open(objFSDirectory);

                    searcher    =   new IndexSearcher(reader);

                } catch (Exception objException) {

                    System.out.println("Exception 1");

                    objException.printStackTrace();

                }

 

 

Thanks

 

Ravi Kumar Jaladanki