# How can I sort all 176 documents by location\_details.circle.gps given that bucket\_sort only sorts the first 10 elements and cannot be used with composite aggregations?

**URL:** <https://discuss.elastic.co/t/how-can-i-sort-all-176-documents-by-location-details-circle-gps-given-that-bucket-sort-only-sorts-the-first-10-elements-and-cannot-be-used-with-composite-aggregations/364067>\
**Category:** Elasticsearch\
**Created:** [July 30, 2024, 2:11pm UTC](https://discuss.elastic.co/t/how-can-i-sort-all-176-documents-by-location-details-circle-gps-given-that-bucket-sort-only-sorts-the-first-10-elements-and-cannot-be-used-with-composite-aggregations/364067 "2024-07-30T14:11:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tirthankar\_Roy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tirthankar_roy/32/124187_2.png) [@Tirthankar\_Roy](https://discuss.elastic.co/u/Tirthankar_Roy)\
**Post date:** [July 30, 2024, 2:11pm UTC](https://discuss.elastic.co/t/how-can-i-sort-all-176-documents-by-location-details-circle-gps-given-that-bucket-sort-only-sorts-the-first-10-elements-and-cannot-be-used-with-composite-aggregations/364067/1 "2024-07-30T14:11:47Z")

</div>

I have 176 documents and I want to sort them based on the location\_details.circle.gps field. Here is my mapping:  
"location\_details": {  
"properties": {  
"address": {  
"properties": {  
"area\_code": { "type": "keyword", "index": false },  
"building": { "type": "keyword", "index": false },  
"city": { "type": "keyword", "index": false },  
"country": { "type": "keyword", "index": false },  
"door": { "type": "keyword", "index": false },  
"locality": { "type": "keyword", "index": false },  
"name": { "type": "keyword", "index": false },  
"state": { "type": "keyword", "index": false },  
"street": { "type": "keyword", "index": false }  
}  
},  
"average\_time\_to\_ship": { "type": "float" },  
"circle": {  
"properties": {  
"\_id": { "type": "keyword", "index": false },  
"gps": { "type": "geo\_point" },  
"radius": {  
"properties": {  
"unit": { "type": "keyword", "index": false },  
"value": { "type": "keyword", "index": false }  
}  
}  
}  
},  
"gps": { "type": "geo\_point" }  
}  
}  
Since `bucket_sort` and `composite` aggregations cannot be used together, and `bucket_sort` only sorts the first 10 elements, how can I achieve sorting all elements based on `location_details.circle.gps`? Any help would be highly appreciated as I am running on a tight deadline

---

<div class="post-metadata">

**Author:** ![nfeekery](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nfeekery/32/117349_2.png) [@nfeekery](https://discuss.elastic.co/u/nfeekery)\
**Post date:** [August 2, 2024, 8:32am UTC](https://discuss.elastic.co/t/how-can-i-sort-all-176-documents-by-location-details-circle-gps-given-that-bucket-sort-only-sorts-the-first-10-elements-and-cannot-be-used-with-composite-aggregations/364067/2 "2024-08-02T08:32:31Z")

</div>

Category updated on August 2, 2024, 8:32am UTC

From #Elastic Search to #Elasticsearch

---

<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:** [August 30, 2024, 8:32am UTC](https://discuss.elastic.co/t/how-can-i-sort-all-176-documents-by-location-details-circle-gps-given-that-bucket-sort-only-sorts-the-first-10-elements-and-cannot-be-used-with-composite-aggregations/364067/3 "2024-08-30T08:32:43Z")

</div>

Closed on August 30, 2024, 8:32am UTC

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