0

I'm following this blog to implement autocomplete feature. I tried creating the exact mapping but stumbled upon some error.

Following is my intended mapping query.

curl -XPUT "http://localhost:9200/blurays " -d'
{
   "settings": {
      "analysis": {
         "filter": {
            "nGram_filter": {
               "type": "nGram",
               "min_gram": 2,
               "max_gram": 20,
               "token_chars": [
                  "letter",
                  "digit",
                  "punctuation",
                  "symbol"
               ]
            }
         },
         "analyzer": {
            "nGram_analyzer": {
               "type": "custom",
               "tokenizer": "whitespace",
               "filter": [
                  "lowercase",
                  "asciifolding",
                  "nGram_filter"
               ]
            },
            "whitespace_analyzer": {
               "type": "custom",
               "tokenizer": "whitespace",
               "filter": [
                  "lowercase",
                  "asciifolding"
               ]
            }
         }
      }
   },
   "mappings": {
      "movies": {
         "_all": {
            "index_analyzer": "nGram_analyzer",
            "search_analyzer": "whitespace_analyzer"
         },
         "properties": {
            "addToCartUrl": {
               "type": "string",
               "index": "no",
               "include_in_all": false
            },
            "format": {
               "type": "string",
               "index": "not_analyzed"
            },
            "mpaaRating": {
               "type": "string",
               "index": "not_analyzed",
               "include_in_all": false
            },
            "price": {
               "type": "double",
               "include_in_all": false
            }
         }
      }
   }
}'

Following is the error that I'm getting:-

analyzer on field [_all] must be set when search_analyzer is set

I'm using the latest version of the ES, ie 2.3 and this was written 2 years back. I've just started learning ES. What can be the possible solution to this?

2 Answers 2

6

When defining the _all field you need to replace index_analyzer with analyzer as this has been renamed in 2.0.

     "_all": {
        "analyzer": "nGram_analyzer",
        "search_analyzer": "whitespace_analyzer"
     },

Agreed, the error message could be better, though.

Sign up to request clarification or add additional context in comments.

1 Comment

Every mapping coming from 1.x to 2.x should be checked for index_analyzer.
0

The index analyzer has been removed in elasticsearch 2.x.

https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_mapping_changes.html#_analyzer_mappings

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.