# Adding sort onto query return results in wrong order

**URL:** <https://discuss.elastic.co/t/adding-sort-onto-query-return-results-in-wrong-order/13170>\
**Category:** Elasticsearch\
**Created:** [August 12, 2013, 4:35am UTC](https://discuss.elastic.co/t/adding-sort-onto-query-return-results-in-wrong-order/13170 "2013-08-12T04:35:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerkywez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerkywez/32/2155_2.png) [@jerkywez](https://discuss.elastic.co/u/jerkywez)\
**Post date:** [August 12, 2013, 4:35am UTC](https://discuss.elastic.co/t/adding-sort-onto-query-return-results-in-wrong-order/13170/1 "2013-08-12T04:35:50Z")

</div>

Hi guys,

Ive got a query that is searching on multiple fields, that works as  
required. I then wanted to sort the results on a date field so i went ahead  
and added a new property mapping for the date field.  
I then added a sort onto the query"

.addSort("publicationdate", SortOrder.DESC);

Now when my results come back, for say searching for a book title of  
'tempted to submit' which used to come back with the correct book as the  
first entry, its now pushed down as the 6th entry, its definatly the sort  
causing this issue.  
Any idea how i can have the original query work as it did but have the  
results sorted by date?

Thanks in advance!

--  
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:21am UTC](https://discuss.elastic.co/t/adding-sort-onto-query-return-results-in-wrong-order/13170/2 "2017-07-06T02:21:40Z")

</div>


