Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

illegal_argument_exception error elasticsearch

Below is my mapping for which I am trying to create an index in my elastic instance. I am creating an analyzer and tokenizer to analyze a url. I am using a custom elasticsearch analyzer which is already installed in my elasticsearch instance. My elasticsearch version is 5.6.16.

curl -X PUT localhost:9200/example-test?pretty -H 'Content-Type: application/json' -d'{
    "settings": {
        "analysis": {
            "filter": {
                "url_host": {
                    "type": "url",
                    "part": [
                        "protocol",
                        "whole",
                        "host",
                        "port",
                        "path",
                        "query",
                        "ref"
                    ],
                    "url_decode": true,
                    "allow_malformed": true,
                    "passthrough": true,
                    "tokenize_malformed": true
                }
            },
            "analyzer": {
                "url_host": {
                    "filter": [
                        "url_host",
                        "lowercase"
                    ],
                    "tokenizer": "split_on_non_word"
                }
            },
            "tokenizer": {
                "split_on_non_word": {
                    "type": "pattern",
                    "pattern": "\\W+"
                }
            }
        },
        "mappings": {
            "example_type": {
                "properties": {
                    "url": {
                        "type": "text",
                        "fields": {
                            "url": {
                                "type": "string"
                            },
                            "host": {
                                "type": "string",
                                "analyzer": "url_host"
                            }
                        }
                    }
                }
            }
        }
    }
}'

But when I tried to create it, I am getting the below error.

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The mappings section should be a sibling of the settings section. This will work:

curl -X PUT localhost:9200/example-test?pretty -H 'Content-Type: application/json' -d'{
  "settings": {
    "analysis": {
      "filter": {
        "url_host": {
          "type": "url",
          "part": [
            "protocol",
            "whole",
            "host",
            "port",
            "path",
            "query",
            "ref"
          ],
          "url_decode": true,
          "allow_malformed": true,
          "passthrough": true,
          "tokenize_malformed": true
        }
      },
      "analyzer": {
        "url_host": {
          "filter": [
            "url_host",
            "lowercase"
          ],
          "tokenizer": "split_on_non_word"
        }
      },
      "tokenizer": {
        "split_on_non_word": {
          "type": "pattern",
          "pattern": ""
        }
      }
    }
  },
  "mappings": {
    "example_type": {
      "properties": {
        "url": {
          "type": "text",
          "fields": {
            "url": {
              "type": "string"
            },
            "host": {
              "type": "string",
              "analyzer": "url_host"
            }
          }
        }
      }
    }
  }
}'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading