# Sort items having the same score by date

**URL:** <https://discuss.elastic.co/t/sort-items-having-the-same-score-by-date/225212>\
**Category:** Elasticsearch\
**Created:** [March 26, 2020, 2:15pm UTC](https://discuss.elastic.co/t/sort-items-having-the-same-score-by-date/225212 "2020-03-26T14:15:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slim-souissi](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@slim-souissi](https://discuss.elastic.co/u/slim-souissi)\
**Post date:** [March 26, 2020, 2:15pm UTC](https://discuss.elastic.co/t/sort-items-having-the-same-score-by-date/225212/1 "2020-03-26T14:15:33Z")

</div>

Hello ,  
I need to sort items that matched having same score by a date field .  
This an example of the query

```auto
"sort" : [
"_score",
{ "searchDate" : {"order" : "desc" } }
]

```

This works perfectly .  
Now i want to convert this to java code and here is my code :

```auto
querySourceBuilder.sort("_score", SortOrder.DESC).sort(SEARCH_DATE_FIELD,SortOrder.DESC);

```

but it's sorting all only by date .

---

<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:** [April 23, 2020, 2:15pm UTC](https://discuss.elastic.co/t/sort-items-having-the-same-score-by-date/225212/2 "2020-04-23T14:15:33Z")

</div>

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