Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am new to ElasticSearch & was trying to execute the example mentioned in their home page where I came across this erorr -

"error": { "root_cause": [ "type": "illegal_argument_exception", "reason": "unknown setting [index.mappings.employee.properties.age.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.employee.properties.age.type] 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.employee.properties.experience.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.employee.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.employee.properties.name.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings" "status": 400

The url & body of the post request are as follows -

URL - > http://localhost:9200/company BODY - >

"settings": { "index": { "number_of_shards": 1, "number_of_replicas": 1 "analysis": { "analyzer": { "analyzer-name": { "type": "custom", "tokenizer": "keyword", "filter": "lowercase" "mappings": { "employee": { "properties": { "age": { "type": "long" "experience": { "type": "long" "name": { "type": "string", "analyzer": "analyzer-name"

How to fix the error ?

There are two errors in syntax of your JSON body object:

  • Node settings must have only two childs: index and analysis . Node mappings must be root-level.
  • Field name has invalid type string , it must be text or keyword . Because you need this field to be analyzed, it should be text in your case.
  • So working query for ES version 6.x (that was current at the time of the question) should be like this:

    "settings": { "index": { "number_of_shards": 1, "number_of_replicas": 1 "analysis": { "analyzer": { "analyzer-name": { "type": "custom", "tokenizer": "keyword", "filter": "lowercase" "mappings": { "employee": { "properties": { "age": { "type": "long" "experience": { "type": "long" "name": { "type": "text", "analyzer": "analyzer-name"

    Starting from ES version 7.0, mapping types was removed from index definition, so the query above wouldn't work in ES 7.x.

    Working query for ES version 7.x could be two types:

  • If index should contain data only about employees, you can simply delete employee mapping type and query would be like this:

    "settings": { "index": { "number_of_shards": 1, "number_of_replicas": 1 "analysis": { "analyzer": { "analyzer-name": { "type": "custom", "tokenizer": "keyword", "filter": "lowercase" "mappings": { "properties": { "age": { "type": "long" "experience": { "type": "long" "name": { "type": "text", "analyzer": "analyzer-name"
  • If index should contain data about employees and some other data, you can use employee as field of the object type and query would be like this:

    "settings": { "index": { "number_of_shards": 1, "number_of_replicas": 1 "analysis": { "analyzer": { "analyzer-name": { "type": "custom", "tokenizer": "keyword", "filter": "lowercase" "mappings": { "properties": { "employee": { "properties": { "age": { "type": "long" "experience": { "type": "long" "name": { "type": "text", "analyzer": "analyzer-name" @user3898336, what version of Elasticsearch do you use? I verify my answer on 6.* (which was relevant at the time of writing the answer) and it works, but now relevant version is 7.* and there are many breaking changes between these versions. Alexey Prudnikov Nov 11, 2019 at 15:50 Hi @SameeraDeSilva, I updated my answer with examples for ES version 7.x. Original example doesn't work in 7.x due to breaking changes between 6.x and 7.x. Alexey Prudnikov Oct 9, 2020 at 8:59
    As you mentioned that you are new to Elastic Search, better start with the basic and use the default settings of ElasticSearch. Use the following mapping:
    curl -XPUT localhost:9200/company -d '{
        "mappings": {
            "employee": {
                "properties": {
                    "age": {"type": "long"},
                    "experience": {"type": "long"},
                    "name": {"type": "string","index": "not_analyzed"}
                    Note that your example will work only for versions of Elasticsearch prior to 5.0, because of breaking changes in syntax - datatype string was splitted in text and keyword datatypes.
    – Alexey Prudnikov
                    Aug 24, 2018 at 11:33
            

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •