How to use TermQuery() to find particular document in the index
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lingaraju_ts
Posted On:   Monday, July 26, 2004 10:42 PM

I am having three fields in the index. One field(Field.Keyword) is acting like a primary key.

When I want insert(add) the record(Document) into the index I need to check that this document present in the index or not. If not present then only I have to add the document to avoid the duplication



By using TermQuery is it possible or is there any other way

Re: How to use TermQuery() to find particular document in the index

Posted By:   Otis_Gospodnetic  
Posted On:   Wednesday, July 28, 2004 02:50 AM

Yes, that is how you should check if a certain term exists in your index. Create your Term, then create TermQuery and pass it your Term in the constructor. Then pass that TermQuery to IndexSearcher's search method and get Hits back. Use Hits' .length() method to see if your Term exists in the index or not.
About | Sitemap | Contact