# Not sorted numeric doc values

**URL:** https://discuss.elastic.co/t/not-sorted-numeric-doc-values/92999
**Category:** Elasticsearch
**Created:** [July 13, 2017, 11:25am UTC](https://discuss.elastic.co/t/not-sorted-numeric-doc-values/92999 "2017-07-13T11:25:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Pawel\_Rog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_rog/32/141223_2.png) [@Pawel\_Rog](https://discuss.elastic.co/u/Pawel_Rog)
#### Post date: [July 13, 2017, 11:25am UTC](https://discuss.elastic.co/t/not-sorted-numeric-doc-values/92999/1 "2017-07-13T11:25:55Z")

</div>

Hello.  
Is there any chance to store floating point numeric doc values in not sorted version?

To give you a little background: I send documents to ES and they have a field which is a vector of floats. Later I use these float values in a script (scoring). The order of float values in vector matters but in my script function, I always get values which are sorted. I quickly scanned ES code and saw many places where Sorted DV are used. Is there any way to change this behavior? Of course, I could use binary data but this will not be convenient because it will be like reinventing a wheel.

Thanks 🙂

---

<div class="post-metadata">

### Author: ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)
#### Post date: [July 21, 2017, 3:08pm UTC](https://discuss.elastic.co/t/not-sorted-numeric-doc-values/92999/2 "2017-07-21T15:08:53Z")

</div>

Unfortunately, there's no way to opt out of sorted doc values. The sorting is done to help compression (when sorted, the values delta-compress better).

There are three workarounds, but none are great. The first is to access the document's `_source`, which gives you access to the original JSON. Unfortunately, the source has to be loaded off disk and decompressed for each document... it'll be a lot slower than doc values.

The second option is to store the values in a `nested` field, where each value is a different "nested document". This maintains order but isn't really useful from a script.

The last option is to store the vector in a string, and then just parse that string into numerics inside your script. It'll have a bit of overhead due to the string parsing, and won't compress as well in the index as a string vs. array of numerics... but you'll be able to retain ordering.

---

<div class="post-metadata">

### Author: ![Pawel\_Rog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_rog/32/141223_2.png) [@Pawel\_Rog](https://discuss.elastic.co/u/Pawel_Rog)
#### Post date: [July 21, 2017, 3:23pm UTC](https://discuss.elastic.co/t/not-sorted-numeric-doc-values/92999/3 "2017-07-21T15:23:24Z")

</div>

Thank you for your answer @polyfractal. I decided to use 4th version which I wanted to avoid but will be the fastest one: - binary doc values. Thank you very much once again 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 18, 2017, 3:23pm UTC](https://discuss.elastic.co/t/not-sorted-numeric-doc-values/92999/4 "2017-08-18T15:23:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
