lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Baroukh" <mbaro...@cardiweb.com>
Subject IndexReader/IndexSearcher
Date Wed, 19 Dec 2001 11:57:12 GMT

Hi all.

Can somebody tell me where is my error.
There is something I don't understand.

If I search something with

    IndexReader indexReader = IndexReader.open("/myindex");
    TermDocs docs = indexReader.termDocs(new Term("codman", "BO23"));
    while ( (docs!=null) && (docs.next()) ) {
        nbis++;
    }
    if (docs!=null) docs.close();
    indexReader.close();

I see that nbis = 0 so temDocs returned nothing.

But, If I use

    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    IndexSearcher indexSearcher = new IndexSearcher("/myindex");
    Query query = QueryParser.parse("BO23", "codman", analyzer);
    Hits hits = indexSearcher.search(query);
    nbis = hits.length();

It's exactly the same query, the same index but this time, it return 1
document.

I don't understand where this difference came from ?
I know that the firs way is not the good way of searching but what I wan't
is to delete from the index the document returned wy the search #2.

Thanks in advance for any help.

Mike



--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message