2

I am creating a way to search for words in Thai by Elasticsearch and Kibana. I have a problem with mapping.

PUT test
{
  "settings": {
    "analysis": {
      "analyzer": {
        "trigrams": {
          "tokenizer": "trigram_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "trigram_tokenizer": {
          "type": "ngram",
          "min_ngram": 3,
          "max_ngram": 3,
          "token_chars": []
        }
      }
    }
  },
  "mappings": {
    "true_name": {
      "properties": {
        "correct": { "type": "text", "analyzer": "trigrams" }
      }
    }
  }
}

and error like this

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters:  [true_name : {properties={correct={analyzer=trigrams, type=text}}}]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [true_name : {properties={correct={analyzer=trigrams, type=text}}}]",
    "caused_by" : {
      "type" : "mapper_parsing_exception",
      "reason" : "Root mapping definition has unsupported parameters:  [true_name : {properties={correct={analyzer=trigrams, type=text}}}]"
    }
  },
  "status" : 400
}

1 Answer 1

3

Mapping types are deprecated. Refer to this documentation to know more about the removal of mapping types.

Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Types will be deprecated in APIs in Elasticsearch 7.0.0, and completely removed in 8.0.0.

{
  "settings": {
    "analysis": {
      "analyzer": {
        "trigrams": {
          "tokenizer": "trigram_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "trigram_tokenizer": {
          "type": "ngram",
          "min_ngram": 3,
          "max_ngram": 3,
          "token_chars": []
        }
      }
    }
  },
  "mappings": {            // note this
    "properties": {
      "correct": {
        "type": "text",
        "analyzer": "trigrams"
      }
    }
  }
}

If your JSON document is like this:

{
  "true_name": {
    "correct": "mapping types deprecated"
  }
}

Then index mapping will be -

{
  "settings": {
    "analysis": {
      "analyzer": {
        "trigrams": {
          "tokenizer": "trigram_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "trigram_tokenizer": {
          "type": "ngram",
          "min_ngram": 3,
          "max_ngram": 3,
          "token_chars": []
        }
      }
    }
  },
  "mappings": {
    "properties": {              // note this
      "true_name": {
        "properties": {
          "correct": {
            "type": "text",
            "analyzer": "trigrams"
          }
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

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.