# Sorting on missing values and using search\_after

**URL:** <https://discuss.elastic.co/t/sorting-on-missing-values-and-using-search-after/195883>\
**Category:** Elasticsearch\
**Created:** [August 20, 2019, 10:14am UTC](https://discuss.elastic.co/t/sorting-on-missing-values-and-using-search-after/195883 "2019-08-20T10:14:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taha\_Nemat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/taha_nemat/32/52594_2.png) [@Taha\_Nemat](https://discuss.elastic.co/u/Taha_Nemat)\
**Post date:** [August 20, 2019, 10:14am UTC](https://discuss.elastic.co/t/sorting-on-missing-values-and-using-search-after/195883/1 "2019-08-20T10:14:55Z")

</div>

Elasticsearch Version 7.0.0  
Node.js client  
Node module: elasticsearch

Hi, I'm trying to fetch a set of documents from elasticsearch using the node.js client (node module: elasticsearch). The problem I'm running into is that when sorting based on some field (with data type long) that can have missing values, elasticsearch responds with a very large number 9223372036854775807 but for some reason, it gets converted into 9223372036854776000 (which is slightly larger) when using the node.js client. I wish to know:

- Why is the number mutating?
- Can this be handled somehow by tweaking some configuration in elasticsearch?
- If not in elasticsearch, is there an elegant way to solve this within the node.js client?

Thank you.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 20, 2019, 11:41am UTC](https://discuss.elastic.co/t/sorting-on-missing-values-and-using-search-after/195883/2 "2019-08-20T11:41:56Z")

</div>

Hey,

my non validated assumption: you might be hitting this javascript behaviour: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Number/MAX\_SAFE\_INTEGER](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)

I'll see if someone knows more about how to circumvent this than me 🙂

--Alex

---

<div class="post-metadata">

**Author:** ![Taha\_Nemat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/taha_nemat/32/52594_2.png) [@Taha\_Nemat](https://discuss.elastic.co/u/Taha_Nemat)\
**Post date:** [August 20, 2019, 12:21pm UTC](https://discuss.elastic.co/t/sorting-on-missing-values-and-using-search-after/195883/3 "2019-08-20T12:21:50Z")

</div>

Yes, I believe you're right and thanks I would really appreciate that.

---

<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:** [September 17, 2019, 12:21pm UTC](https://discuss.elastic.co/t/sorting-on-missing-values-and-using-search-after/195883/4 "2019-09-17T12:21:58Z")

</div>

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