# The order of the result doesn't work properly?

**URL:** <https://discuss.elastic.co/t/the-order-of-the-result-doesnt-work-properly/5073>\
**Category:** Elasticsearch\
**Created:** [August 6, 2011, 12:00am UTC](https://discuss.elastic.co/t/the-order-of-the-result-doesnt-work-properly/5073 "2011-08-06T00:00:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kun\_Niu](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kun\_Niu](https://discuss.elastic.co/u/Kun_Niu)\
**Post date:** [August 6, 2011, 12:00am UTC](https://discuss.elastic.co/t/the-order-of-the-result-doesnt-work-properly/5073/1 "2011-08-06T00:00:18Z")

</div>

Hi all,  
I don't know if anyone has the same problem with me.  
I do a search using transport client and called addSort like this:  
addSort("FILE\_OFFSET", SortOrder.DESC)  
I have three records in elasticsearch server with "FILE\_OFFSET" - 340,  
760, 1100.  
It seems that each time I search the result, I can only find the  
result with 760 as FILE\_OFFSET.  
Can anyone here help me with this issue?

Thanks and best regards,  
Kun

---

<div class="post-metadata">

**Author:** ![Kun\_Niu](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kun\_Niu](https://discuss.elastic.co/u/Kun_Niu)\
**Post date:** [August 7, 2011, 6:33am UTC](https://discuss.elastic.co/t/the-order-of-the-result-doesnt-work-properly/5073/2 "2011-08-07T06:33:11Z")

</div>

Hi all,  
I found that the search order is based on string.  
But I want to set the search order based on long value.  
Can anyone here tell me how to set the search order based on long  
value instead of string value?  
I'm using Java API.

Thanks and best regards,  
Kun

On Aug 5, 5:00 pm, Rent a room [haoniu...@gmail.com](mailto:haoniu...@gmail.com) wrote:

> Hi all,  
> I don't know if anyone has the same problem with me.  
> I do a search using transport client and called addSort like this:  
> addSort("FILE\_OFFSET", SortOrder.DESC)  
> I have three records in elasticsearch server with "FILE\_OFFSET" - 340,  
> 760, 1100.  
> It seems that each time I search the result, I can only find the  
> result with 760 as FILE\_OFFSET.  
> Can anyone here help me with this issue?
> 
> Thanks and best regards,  
> Kun

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [August 7, 2011, 8:10pm UTC](https://discuss.elastic.co/t/the-order-of-the-result-doesnt-work-properly/5073/3 "2011-08-07T20:10:32Z")

</div>

You can do it by specifying "long" type for the FILE\_OFFSET field in  
your index mapping. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)  
for more information.

On Aug 7, 2:33 am, kun niu [haoniu...@gmail.com](mailto:haoniu...@gmail.com) wrote:

> Hi all,  
> I found that the search order is based on string.  
> But I want to set the search order based on long value.  
> Can anyone here tell me how to set the search order based on long  
> value instead of string value?  
> I'm using Java API.
> 
> Thanks and best regards,  
> Kun
> 
> On Aug 5, 5:00 pm, Rent a room [haoniu...@gmail.com](mailto:haoniu...@gmail.com) wrote:
> 
> > Hi all,  
> > I don't know if anyone has the same problem with me.  
> > I do a search using transport client and called addSort like this:  
> > addSort("FILE\_OFFSET", SortOrder.DESC)  
> > I have three records in elasticsearch server with "FILE\_OFFSET" - 340,  
> > 760, 1100.  
> > It seems that each time I search the result, I can only find the  
> > result with 760 as FILE\_OFFSET.  
> > Can anyone here help me with this issue?
> 
> > Thanks and best regards,  
> > Kun

---

<div class="post-metadata">

**Author:** ![Kun\_Niu](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kun\_Niu](https://discuss.elastic.co/u/Kun_Niu)\
**Post date:** [August 8, 2011, 3:43am UTC](https://discuss.elastic.co/t/the-order-of-the-result-doesnt-work-properly/5073/4 "2011-08-08T03:43:29Z")

</div>

Right. I got it.  
Thanks a lot.

> -----Original Message-----  
> From: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] On Behalf Of imotov  
> Sent: 2011年8月8日 4:11  
> To: elasticsearch  
> Subject: Re: The order of the result doesn't work properly?
> 
> You can do it by specifying "long" type for the FILE\_OFFSET field in your index  
> mapping. See  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)  
> for more information.
> 
> On Aug 7, 2:33 am, kun niu [haoniu...@gmail.com](mailto:haoniu...@gmail.com) wrote:
> 
> > Hi all,  
> > I found that the search order is based on string.  
> > But I want to set the search order based on long value.  
> > Can anyone here tell me how to set the search order based on long  
> > value instead of string value?  
> > I'm using Java API.
> > 
> > Thanks and best regards,  
> > Kun
> > 
> > On Aug 5, 5:00 pm, Rent a room [haoniu...@gmail.com](mailto:haoniu...@gmail.com) wrote:
> > 
> > > Hi all,  
> > > I don't know if anyone has the same problem with me.  
> > > I do a search using transport client and called addSort like this:  
> > > addSort("FILE\_OFFSET", SortOrder.DESC) I have three records in  
> > > elasticsearch server with "FILE\_OFFSET" - 340, 760, 1100.  
> > > It seems that each time I search the result, I can only find the  
> > > result with 760 as FILE\_OFFSET.  
> > > Can anyone here help me with this issue?
> > 
> > > Thanks and best regards,  
> > > Kun

---

<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, 3:58am UTC](https://discuss.elastic.co/t/the-order-of-the-result-doesnt-work-properly/5073/5 "2017-07-06T03:58:00Z")

</div>


