I wish to create an index with, lets say the following fields :
UID
title
owner
content
out of which, I don’t want UID to be searchable. [ like meta data ]
I want the UID to behave like docID so that when I want to delete or update,
I’ll use this.
Is this possible ? How to do this ?
You could mark is as non-searchable by adding it with
Store.YESandIndex.NO, but that wont allow you easy updating/removal by using it. You’ll need to index the field to allow replacing it (usingIndexWriter.UpdateDocument(Term, Document)where term =new Term("UID", "...")), so you need to use eitherIndex.ANALYZEDwith aKeywordAnalyzer, orIndex.NOT_ANALYZED. You can also use theFieldCacheif you have a single-valued field, which a primary key usually is. However, this makes it searchable.Summary:
Store.NO(It can be retrieved using theFieldCacheor aTermsEnum)Index.NOT_ANALYZED(The complete value will be indexed as a term, including any whitespaces)