Document Array Sorted

Hi everyone,

I have the following issue i have a list of documents that should store a key/value map as a scoring script is using them to score results upon a key/value map passed as parameter.

As from what I found out, doc[] can only load arrays (the size of this map is small compared to the rest of the document so I'm trying to avoid _source) i rearranged the key/value map in:

"key"=["1","4","7","8"]
"val"=[0.7,0.4,0.6,0.2]

But I found out that one of those (or maybe both) when retrived with doc[].values all array elements are rearranged in ascending order that destroy the map structure.

I was browsing quite a long time about this issue, but i was unable to figure out how can I approach this problem to solve it in the best way.

Any advice?