# Best way of getting X before and Y after long Z

**URL:** <https://discuss.elastic.co/t/best-way-of-getting-x-before-and-y-after-long-z/11813>\
**Category:** Elasticsearch\
**Created:** [May 4, 2013, 5:49pm UTC](https://discuss.elastic.co/t/best-way-of-getting-x-before-and-y-after-long-z/11813 "2013-05-04T17:49:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin\_Verlangen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robin_verlangen/32/1542_2.png) [@Robin\_Verlangen](https://discuss.elastic.co/u/Robin_Verlangen)\
**Post date:** [May 4, 2013, 5:49pm UTC](https://discuss.elastic.co/t/best-way-of-getting-x-before-and-y-after-long-z/11813/1 "2013-05-04T17:49:33Z")

</div>

Hi there,

What's the best way in terms of performance to get for example 5 documents  
before, and 10 documents after, around a certain long value?

The long value is an internal sequence number which is atomic for the order  
of documents.

Best regards,

Robin Verlangen  
_Data Architect_  
\*  
\*  
W [http://www.robinverlangen.nl](http://www.robinverlangen.nl)  
E robin@us2.nl

[http://goo.gl/Lt7BC](http://goo.gl/Lt7BC)

Disclaimer: The information contained in this message and attachments is  
intended solely for the attention and use of the named addressee and may be  
confidential. If you are not the intended recipient, you are reminded that  
the information remains the property of the sender. You must not use,  
disclose, distribute, copy, print or rely on this e-mail. If you have  
received this message in error, please contact the sender immediately and  
irrevocably delete this message and any copies.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://discuss.elastic.co/u/phill)\
**Post date:** [May 6, 2013, 4:20pm UTC](https://discuss.elastic.co/t/best-way-of-getting-x-before-and-y-after-long-z/11813/2 "2013-05-06T16:20:23Z")

</div>

On 5/4/2013 10:49 AM, Robin Verlangen wrote:

> Hi there,
> 
> What's the best way in terms of performance to get for example 5  
> documents before, and 10 documents after, around a certain long value?
> 
> The long value is an internal sequence number which is atomic for the  
> order of documents.

Have you looked into numeric range queries?

-Paul

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Robin\_Verlangen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robin_verlangen/32/1542_2.png) [@Robin\_Verlangen](https://discuss.elastic.co/u/Robin_Verlangen)\
**Post date:** [May 8, 2013, 8:29am UTC](https://discuss.elastic.co/t/best-way-of-getting-x-before-and-y-after-long-z/11813/3 "2013-05-08T08:29:02Z")

</div>

Hi Paul,

Yes, for some reason I totally missed this while looking at the  
documentation. I already implemented it and it works just fine.

Thanks!

Best regards,

Robin Verlangen  
_Data Architect_  
\*  
\*  
W [http://www.robinverlangen.nl](http://www.robinverlangen.nl)  
E robin@us2.nl

[http://goo.gl/Lt7BC](http://goo.gl/Lt7BC)

Disclaimer: The information contained in this message and attachments is  
intended solely for the attention and use of the named addressee and may be  
confidential. If you are not the intended recipient, you are reminded that  
the information remains the property of the sender. You must not use,  
disclose, distribute, copy, print or rely on this e-mail. If you have  
received this message in error, please contact the sender immediately and  
irrevocably delete this message and any copies.

On Mon, May 6, 2013 at 6:23 PM, Paul Hill [parehill1@gmail.com](mailto:parehill1@gmail.com) wrote:

> On 5/4/2013 10:49 AM, Robin Verlangen wrote:
> 
> > Hi there,
> > 
> > What's the best way in terms of performance to get for example 5  
> > documents before, and 10 documents after, around a certain long value?
> > 
> > The long value is an internal sequence number which is atomic for the  
> > order of documents.
> > 
> > Have you looked into numeric range queries?
> 
> -Paul
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to elasticsearch+unsubscribe@\*\*[googlegroups.com](http://googlegroups.com)[elasticsearch%2Bunsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> .

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:37am UTC](https://discuss.elastic.co/t/best-way-of-getting-x-before-and-y-after-long-z/11813/4 "2017-07-06T02:37:41Z")

</div>


