java - Is there any option to stop applying analyzer? -


hi developing mini application using elastic search.

setting :-

        settingbuilder = xcontentfactory.jsonbuilder().startobject()                 .startobject("index")                 .startobject("analysis")                 .startobject("analyzer")                 .startobject("custom_analyzer")                 .field("type", "custom")                 .field("tokenizer","keyword")                 .field("filter", new string[]{"standard","ngram_filters"})                 .endobject()                 .endobject()                 .startobject("filter")                 .startobject("ngram_filters")                 .field("type", "ngram")                 .field("min_gram", "1")                 .field("max_gram","10")                 .endobject()                 .endobject()                 .endobject()                 .endobject()                 .endobject(); 

mapping :-

        contentbuilder = xcontentfactory.jsonbuilder().startobject()         .startobject("students")         .startobject("properties")         .startobject("searchcolumn")         .field("analyzer", "custom_analyzer")         .field("type", "string")         .endobject()         .startobject("firstname")         .field("type","string")         .field("analyzer", "custom_analyzer")         .field("store", "yes")         .endobject()         .startobject("lastname")         .field("type","string")         .field("analyzer", "custom_analyzer")         .field("store", "yes")         .endobject()         .startobject("registernumber")         .field("type", "long")         .field("analyzer", "custom_analyzer")         .field("store", "yes")         .endobject()         .endobject()         .endobject()         .endobject(); 

here specified ngram filter. reason while doing search process dont want apply analyzer prefixfilter or prefixquery. there option. issue facing here is,

for eg.

    apple     1 apple     2 apple  

assume firstname values example. when search prefix character 'a', must want 'apple' document. right now, getting results because of ngram... can u please solution this?

when define mapping string fields can define different analyzers applied @ index time , query time, using index_analyzer , search_analyzer property. you're using analyzer property shortcut apply same analyzer @ both index , query time. in fact have similar, if not equal, text analysis chain applied @ index time , query time, ngrams exception since don't want make ngrams out of queries.

you define 2 different analyzers, 1 makes ngrams , other doesn't. update mapping this:

.startobject("firstname") .field("type","string") .field("index_analyzer", "ngrams_analyzer") .field("search_analyzer", "search_analyzer_without_ngrams") 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -