lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From balasubramanian sudaakeran <sudaakera...@yahoo.com>
Subject Re: Problems searching index
Date Mon, 18 May 2009 14:19:56 GMT

Hi Eric LeVin,
I think whenever you reopen the indexReader you have to re-create indexSearcher also. This
is because reopen of indexReader will give you a new instance if the underlying data is changed.

Function documentation for IndexReader.reopen
   * If the index has not changed since this instance was (re)opened, then this
   * call is a NOOP and returns this instance. Otherwise, a new instance is 
   * returned. The old instance is <b>not</b> closed and remains usable.<br>
   * <b>Note:</b> The re-opened reader instance and the old instance might share
   * the same resources. For this reason no index modification operations 
   * (e. g. {@link #deleteDocument(int)}, {@link #setNorm(int, String, byte)}) 
   * should be performed using one of the readers until the old reader instance
   * is closed. <b>Otherwise, the behavior of the readers is undefined.</b> 
   * <p>   




----- Original Message ----
From: Eric LeVin <ejlevin1.dev@gmail.com>
To: java-user@lucene.apache.org
Sent: Monday, May 18, 2009 7:30:47 PM
Subject: Problems searching index

Hi Everyone--
   So I'm not quite sure what is going on with my Lucene index, but I'm having some issues
searching.  I've created a simple little index of 10 documents as follows:

id: 1
type: Article
content: <<some content>>

....

id: 10
type: Article
content: <<other content>>

So I created a simple TermQuery for starters that would pull back all of my Article types:

BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(new Term(FIELD_TYPE, "Article")), Occur.MUST);

I realize that I could simply do a TermQuery, but I want to be able to add additional content
constraints after I get this working.  So here is where my confusion comes in:

If I run the query against my IndexSearcher, I get 0 results; however, if I run it as a delete
on the IndexWriter, I can open it in Luke and see the entire index deleted.  So why would
the writer be finding documents and the searcher wouldn't?  As a note, whenever I am adding
documents, I am calling reopen() on the reader.  Here is how I'm creating the writer/reader/searcher:

KeywordAnalyzer ka = new KeywordAnalyzer();
       analyzer.addAnalyzer(FIELD_ID, ka);
       analyzer.addAnalyzer(FIELD_TYPE, ka);
       analyzer.addAnalyzer(FIELD_CONTENT, contentAnalyser);
             indexWriter = new IndexWriter(directory, analyzer, true, MaxFieldLength.UNLIMITED);
       indexReader = IndexReader.open(directory);
       indexSearcher = new IndexSearcher(indexReader);

Any thoughts?  Thanks so much for all the help!

-Eric LeVin

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


      

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


Mime
View raw message