2

I'm trying to get this code to work but I'm getting the below error: Reference : https://www.youtube.com/watch?v=PQGlhbf7o7c

Please let me know how this can be fixed. Thank You.

Code:

PUT test
{
  "settings": {
    "index": {
      "analysis": {
        "filter": {},
        "analyzer": {
          "keyword_analyzer": {
            "filter": [
              "lowercase",
              "asciifolding",
              "trim"
            ],
            "char_filter": [],
            "type": "custom",
            "tokenizer": "keywords"
          },
          "edge_ngram_analyzer": {
            "filter": [
              "lowercase"
            ],
            "tokenizer": "edge_ngram_tokenizer"
          },
          "edge_ngram_search_analyzer": {
            "tokenizer": "lowercase"
          },
          "tokenizer": {
            "edge_ngram_tokenizer": {
              "type": "edge_ngram",
              "min_gram": 2,
              "max_gram": 5,
              "token_chars": [
                "letter"
              ]
            }
          }
        }
      }
    },
    "mappings": {
      "properties": {
        "name": {
          "type": "text",
          "fields": {
            "keywordstring": {
              "type": "text",
              "analyzer": "keyword_analyzer"
            },
            "edgengram": {
              "type": "text",
              "analyzer": "edge_ngram_analyzer",
              "search_analyzer": "edge_ngram_search_analyzer"
            },
            "completion": {
              "type": "completion"
            }
          },
          "analyzer": "standard"
        }
      }
    }
  }
}

Error

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "unknown setting [index.mappings.properties.name.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings",
    "suppressed" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.completion.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.edgengram.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.edgengram.search_analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.edgengram.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.keywordstring.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.keywordstring.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      }
    ]
  },
  "status" : 400
}

1 Answer 1

3

You were almost there but the payload structure when creating an index should like this:

PUT test
{
  "settings": {
    "analysis": {
       ...
    }
  },
  "mappings": {
    "properties": {
       ...
    }
  }
}

In your case this would mean:

PUT test
{
  "settings": {
    "analysis": {
      "filter": {},
      "analyzer": {
        "keyword_analyzer": {
          "filter": [
            "lowercase",
            "asciifolding",
            "trim"
          ],
          "char_filter": [],
          "type": "custom",
          "tokenizer": "keywords"
        },
        "edge_ngram_analyzer": {
          "filter": [
            "lowercase"
          ],
          "tokenizer": "edge_ngram_tokenizer"
        },
        "edge_ngram_search_analyzer": {
          "tokenizer": "lowercase"
        },
        "tokenizer": {
          "edge_ngram_tokenizer": {
            "type": "edge_ngram",
            "min_gram": 2,
            "max_gram": 5,
            "token_chars": [
              "letter"
            ]
          }
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "keywordstring": {
            "type": "text",
            "analyzer": "keyword_analyzer"
          },
          "edgengram": {
            "type": "text",
            "analyzer": "edge_ngram_analyzer",
            "search_analyzer": "edge_ngram_search_analyzer"
          },
          "completion": {
            "type": "completion"
          }
        },
        "analyzer": "standard"
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

5 Comments

Hi @Joe for updating my code. It is throwing another error after adding this code. I've added the error above. Please let me know how i can fix it? Thanks in advance
Will do tomorrow but please edit the question and not the answer.
Sure! Thanks. Also please can you also check this Q also please! I'll really appreciate your help!! Thanks again - stackoverflow.com/questions/66497829/…
Did you figure it out with the tokenizer error?
Yes @Joe. Thanks

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.