Search code examples
elasticsearchopensearch

Elasticsearch cannot index array of integers


Given mapping:

{
    "mappings": {
        "properties": {
            "user_ids": {"type": "integer"}
        }
    }
}

Observations:

  • Index {"user_ids": 1}, and data will show up correctly
  • Index {"user_ids": "x"}, and error is thrown failed to parse field [user_ids] of type [integer] in document, indicating that mapping is working correctly
  • However, indexing {"user_ids": [1]} just clears the field, without throwing error.

Question:

  • Why does this happen and how can I index arrays of integers?

Extra:

  • I removed all settings config, doesn't change anything
  • I tried keyword type, doesn't change anything
  • If relevant, I use latest opensearch-py

Solution

  • Turns out it's my own error: I was using elasticsearch-head for quick checking of values, and they don't support displaying of array values :/ Once I double checked with queries, they came back correct.