1

I have an integer array field, for example, my_integer_array.

I stored [3, 4, 1, 2] on the field via client and I can see that [3, 4, 1, 2] is successfully set on the document's my_integer_array field via Kibana.

But whenever I try to access the field in Painless Elasticsearch scripting language, e.g. doc['my_integer_array'], it returns [1, 2, 3, 4], not [3, 4, 1, 2]. Accessing it's element via doc['my_integer_array'][0] returns 1, not 3.

It seems like Painless provides sorted version of the field's data rather than the original array itself. Am I missing something? Can I disable this behavior and preserve the order?

P.S. I'm using elasticsearch-dsl-py Elasticsearch Python DSL library as an Elasticsearch client.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
June
  • 2,107
  • 4
  • 22
  • 33

1 Answers1

1

You can access the array setting _source:true and then using params._source['my_integer_array'] this way the array will be unsorted in its original state.

Holger Will
  • 7,228
  • 1
  • 31
  • 39