# Sort Based on Subfield Omits Results

**URL:** <https://discuss.elastic.co/t/sort-based-on-subfield-omits-results/122566>\
**Category:** Elasticsearch\
**Created:** [March 5, 2018, 4:51pm UTC](https://discuss.elastic.co/t/sort-based-on-subfield-omits-results/122566 "2018-03-05T16:51:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amirklick](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@amirklick](https://discuss.elastic.co/u/amirklick)\
**Post date:** [March 5, 2018, 4:51pm UTC](https://discuss.elastic.co/t/sort-based-on-subfield-omits-results/122566/1 "2018-03-05T16:51:15Z")

</div>

Hi. I'm using the JavaScript SDK and when I sort results based on a subfield, if I don't specify a "size" greater than or equal to total number of records, some are omitted and not returned. Is this a bug? How can this be fixed without hard coding the size?

**For example:**  
[  
{  
title: "Video 1",  
category: {  
name: "Category 2"  
}  
},  
{  
title: "Video 3",  
category: {  
name: "Category 1"  
}  
},  
{  
title: "Video 2",  
category: {  
name: "Category 2"  
}  
},  
]

**Sorting based on "category.name" without specifying size, returns:**  
[  
{  
title: "Video 3",  
category: {  
name: "Category 1"  
}  
},  
{  
title: "Video 1",  
category: {  
name: "Category 2"  
}  
},  
]

Thanks!

---

<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 2, 2018, 4:51pm UTC](https://discuss.elastic.co/t/sort-based-on-subfield-omits-results/122566/2 "2018-04-02T16:51:20Z")

</div>

Closed on April 2, 2018, 4:51pm UTC

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