I am using Lucene.NET and I would like to check before whether a document is contained in the index, so that if it is, I do not need to store it in the index, but I can skip it. I've read some questions that had the same problem, but they all dealt with deleting and updating it with the new document. I don't want to have to do that since the document will contain the exact same data and it would be useless to store it again. I have a field that acts as an ID called URL where each document contains its specific URL. therefore there is a way for me to identify the specific document, I just don't know what condition I should use.
Any help?
I would use something like this:
IndexReader reader;
Term indexTerm = new Term(FieldNames.UniqueId, itemId.ToString());
TermDocs docs = reader.TermDocs(indexTerm);
if (docs.Next())
{
continue;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.