Search code examples
elasticsearchelasticsearch-py

Mapping to limit length of Array datatype in Elasticsearch


I'm trying to create an elasticsearch Mapping which limits the length of an array datatype to x number of items.

mapping = """
{
"mappings": {
        "document": {
            "properties": {
                "pages": {
                    "type": "text"
               }
            }
        }
    }
}
}
"""

in this case, how do I set the "pages" array to have a maximum of 1,000 list items? Also, is there a way to "ignore" insert errors triggered by ES when this limit has been reached?


Solution

  • Elasticsearch has no such limits, you'd have to enforce it in your application.

    As for ignoring errors look at the ignore_malformed option for many fields.

    Hope this helps!