Question

I am having problem understanding the Field.Index from Lucene .NET enumeration.

The options available are analyzed/not_analyzed/no/analyzed_no_norms/not_analyzed_no_norms.

I have made my own research but I am still confused on when should I use analyzed or not analyzed (since I guess their are the two main options).

For example if I build an Index :

class Product{ 
 public int Id {get;set;}
 public string Name {get;set;}
 public double Price { get; set; }
}

And I mainly query using a combination of Name must be "something" and price in range of 10 < x < 20. Here's the query I am using :

Query nameQuery= new QueryParser(Version.LUCENE_30, "Name", 
new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30)).Parse(nameTerm);
NumericRangeQuery<double> priceRangeQuery = 
NumericRangeQuery.NewDoubleRange("Close", lowerband, upperband, true, true);
BooleanQuery query = new BooleanQuery();
query.Add(nameQuery, Occur.MUST);
query.Add(priceRangeQuery , Occur.MUST);

If I query this way, should I analyze/not_analyze the Id/Name/Price ? Also what would be the impact of setting Field.Store to Yes/No ? Could someone explain it to me in layman terms?

Thank you very much

Was it helpful?

Solution

Analyzed means that the field is tokenized and post-processed (e.g. lowercased) using the specified analyzer and each single token is mapped in the index to that particular document so you can search for this token and find the document. Otherwise you can only search for the whole text of the field to find the document.

The option "no" which stands for not indexing means that the content of the field is not used for indexing. So you can't find the document using the content of the field.

In you case if you don't search in the "id" field you don't need to index it. If you search in it but only with the exact content you only need to index it without analyzing.

You should analyze the name field since you search for single token in there.

numeric fields should also be analyzed.

Field.Store = YES means that if you have retrieved a lucene document, you can read the value of the particular field just like from a db.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top