Hello,

>I want to write a function countIndexEntries(key) to find out how many
>entries are there in the index database for a key. I read the faq entry
>about counting number of hits, but somehow it doesnt work as expected,
>please help:

>I create entries with
                indexDocument.add(Field.Keyword(FULLTEXT_KEY_FIELD,key));
        
indexDocument.add(Field.Text(FULLTEXT_CONTENTS_FIELD,reader));
                indexwriter.addDocument(indexDocument);

>I try to count the number of entries for a key with
                Query query = QueryParser.parse(key, FULLTEXT_KEY_FIELD,
analyzer);
                count = searcher.search(query).length();

>to find out if something is not yet indexed (count=0), already indexed
>(count=1), or index is inconsistent (count=2). But count is always = 0 :-(

>What is wrong or how to acchieve my goal with a different approach? Help is
>appreciated.
Make sure, that you reopen your searcher after modifing the index. That
means close
it and open it again. Else the searcher won't find your document, because he
doesn't
notify a new created segment containing the last changes.
Regards,
        Wolf-Dietrich Materna

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to