Home > Mobile >  ElasticSearch 8.3.3, custom analyzer "not configured in mappings"
ElasticSearch 8.3.3, custom analyzer "not configured in mappings"

Time:08-22

I am trying to use elasticdump to load a mapping to elastic search. The complete file is shown bellow. Looking to the documentation, it "should work". Nevertheless, I get the error:

Fri, 19 Aug 2022 21:04:48 GMT | Error Emitted => {"root_cause":[{"type":"mapper_parsing_exception","reason":"Failed to parse mapping: analyzer [my_lc_analyzer] has not been configured in mappings"}],
"type":"mapper_parsing_exception","reason":"Failed to parse mapping: analyzer [my_lc_analyzer] has not been configured in mappings","caused_by":{"type":"illegal_argument_exception","reason":"analyzer [my_lc_analyzer] has not been configured in mappings"}}

The complete mappings file is:

{
    "ngrams": {
        "settings": {
            "analysis": {
                "analyzer": {
                    "my_lc_analyzer": {
                        "type": "custom",
                        "tokenizer": "standard",
                        "filter": [
                            "lowercase",
                            "asciifolding"
                        ]
                    }
                }
            }
        },
        "mappings": {
            "properties": {
                "canvas_id": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "document_id": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "id": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "text": {
                    "type": "text",
                    "analyzer": "my_lc_analyzer"
                }
            }
        }
    }
}

I found some examples in the web, where the settings key has an extra level, index, inside it. I tried that too, with no luck.

I suppose I am missing some stupid detail, but not finding it. Thanks in advance

CodePudding user response:

Maybe key "ngram" be the problem.

PUT my-index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_lc_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "asciifolding"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "canvas_id": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "document_id": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "id": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "text": {
        "type": "text",
        "analyzer": "my_lc_analyzer"
      }
    }
  }
}

CodePudding user response:

While I posted in the original question, it was probably disregarded by most readers. I am using elasticdump for dumping and restoring the database.

My main mistake was to edit the dump produced by elasticdump and adding the settings section, to describe the analyzer. And I did this without reading the elasticdump documentation, and it made sense in my head to have a single post to create the index and respective settings.

Nevertheless, that is not the case. elasticdump distinguishes between data, settings, analyzers, mappings and others. And thus, an export of type analyzers must be done, and that is what must be supplied during import (with the specific analyzers type).

While I think elasticdump might have a cleaner interface, I solved my issue, exporting the analyzers, and importing it before the mappings info.

  • Related