Search code examples
elasticsearchfilterautosuggestcompletion

Empty value generates mapper_parsing_exception for Elasticsearch completion suggester field


I have a name field which is a completion suggester, and indexing generates a mapper_parsing_exception error, stating value must have a length > 0.

There are indeed some empty values in this field. How do I accommodate them?

ignore_malformed had no effect, either at the properties or index level.

I tried filtering out empty strings in the analyzer, setting a min length:

PUT /genes
{
  "settings": {
  "analysis": {
      "filter": {
        "remove_empty": {
          "type": "length",
          "min": 1
        }
      },  
      "analyzer": {
        "keyword_lowercase": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": [
            "lowercase", 
            "remove_empty"
          ]
        }
      }
    }
  },
  "mappings": {
    "gene": {
        "name": {
          "type": "completion",
          "analyzer": "keyword_lowercase"
        }
      }
    }
  }
}

Or filter empty strings as a stopword:

    "remove_empty": {
      "type": "stop",
      "stopwords": [""]
    }

Attempting to apply a filter to the name mapping generates an unsupported parameter error:

"mappings": {
    "gene": {
        "name": {
          "type": "completion",
          "analyzer": "keyword_lowercase",
          "filter": "remove_empty"
        }
      }
    }
}

This sure feels like it ought to be simple. Is there a way to do this?

Thanks!


Solution

  • I have faced the same issue. After some research it seems to me that currently the only option is to change data (e.g. replace empty values with some dummy non-empty values) before indexing.

    But there is also good news. This issue exists on GitHub and was resolved about a month ago. It is planned to be released in version 6.4.0.