How to add a full phrase tokenizer to Nest for Elasticsearch?

when I create a search using faces, I want the facet results to be on the whole phrase, and not on a single word. and I want this NOT to be case sensitive - like "not_analyzed".

for example, if I have a musical json object and you want to organize the facet results based on the genre, I want to see each genre as the whole genre term (rhythm and blues), and not one aspect for “rhythm” and one for “blues”, and I want to be able to search for "rhythm and blues" and match it with "Rhythm and Blues" (notification case).

it looks like elasticsearch documentation suggests using a custom tokenizer analyzer and lower case filter.

here is a sentence from elasticsearch that I mentioned: (mid-page) http://www.elasticsearch.org/blog/starts-with-phrase-matching/

I want to be able to say something like (in my POCO in pseudocode):

[ElasticProperty(Analyzer = "tokenizer, lowercase"] public string Genre {get;set;} 
+4
elasticsearch nest
source share
1 answer

Use multi field in your mapping. This will allow you to index the Genre field in two ways - by analyzing (using a standard or line analyzer) for searches, rather than analysis for cutting.

For more advanced mappings, such as attribute-based mapping in NEST, this will not be abbreviated. You will need to use the free API, for example:

 client.CreatIndex("songs", c => c .AddMapping<Song>(m => m .MapFromAttributes() .Properties(props => props .MultiField(mf => mf .Name(s => s.Genre) .Fields(f => f .String(s => s.Name(o => o.Genre).Analyzer("standard")) .String(s => s.Name(o => o.Genre.Suffix("raw")).Index(FieldIndexOption.not_analyzed))))))); 

Hope this helps!

0
source share

All Articles