lucenelucene.netpylucene

what is the use of StringField.TYPE_NOT_STORED


I am trying to understand different Field options provided by Lucene, As per my knowledge Lucene will provide the following field options

TextField.TYPE_STORED - Analyzed & stored
TextField.TYPE_NOT_STORED - Analyzed & Not stored
StringField.TYPE_STORED - Not Analyzed & stored
StringField.TYPE_NOT_STORED - NOT Analyzed & NOT stored

StringField.TYPE_NOT_STORED -- fields will not be able to do a search also retrieve the content. What is the use of adding these type of fields to my Lucene documents?


Solution

  • Not Analyzed doesn't mean it won't be searchable, it means it will be just searched as is. So, for example if your string token is John, than if you will search for john you won't be able to find it. You also won't apply any analyzer/filter to these field.

    Basically, this type is using for something where you do not want to have analyzers and you do not want to retrieve it, like id lookups or something similar.