pinkpanther
pinkpanther

Reputation: 4808

What happens when not_analyzed and analyzer is used in same mapping?

In elastic search mapping, as per my knowledge, index:not_analyzed means it indexes the value as it is with out analyzing.

and

When we want to specify an analyzer we can use analyzer:<some-analyzer>.

I've seen some people using both the settings for the same field like

"property":{
    "type":"string",
    "index":"not_analyzed",
    "analyzer":"analyzer_keyword"
 }

What is the effect of above setting, it seems contradictory to me. Am I missing something?

Upvotes: 1

Views: 531

Answers (1)

keety
keety

Reputation: 17441

At least in ES 1.6 looks like if field is mapped to not_analyzed and the analyzer is specified it overrides the search_analyzer.

i.e the mapping in OP is equivalent to

"property":{
    "type":"string",
    "index":"not_analyzed",
    "search_analyzer":"analyzer_keyword"
 }

A field mapped as not_analyzed has the index analyzer always set to keyword analyzer The default search analyzer for not_analyzed is keyword however looks this can be overridden via analyzer/search_analyzer setting which honestly to me doesn't make sense.

Probably the mapping in OP was done to be compatible with earlier version ES issue where looks like standard analyzer was the default search analyzer even for fields mapped as not_analyzed

Upvotes: 1

Related Questions