# How to sort results by field's priorities

**URL:** <https://discuss.elastic.co/t/how-to-sort-results-by-fields-priorities/22469>\
**Category:** Elasticsearch\
**Created:** [March 2, 2015, 4:08pm UTC](https://discuss.elastic.co/t/how-to-sort-results-by-fields-priorities/22469 "2015-03-02T16:08:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleg\_Patrushev](https://avatars.discourse-cdn.com/v4/letter/o/22d042/32.png) [@Oleg\_Patrushev](https://discuss.elastic.co/u/Oleg_Patrushev)\
**Post date:** [March 2, 2015, 4:08pm UTC](https://discuss.elastic.co/t/how-to-sort-results-by-fields-priorities/22469/1 "2015-03-02T16:08:41Z")

</div>

My query is

{"filter":{"and":[{"term":{"inSearch":1}},{"query":{"match":{"status":{  
"query":1}}}}]},"sort":{"sequence":{"order":"asc"}},"query":{"bool":{  
"should":[{"match":{"metaKeywords.ngram":{"query":"fossil","operator":"AND",  
"analyzer":"whitespace\_lowercase","boost":2}}},{"nested":{"path":"tags",  
"query":{"match":{"tags.name.ngram":{"query":"fossil","operator":"AND",  
"analyzer":"whitespace\_lowercase","boost":3}}}}},{"nested":{"path":  
"categories","query":{"match":{"categories.name.ngram":{"query":"fossil",  
"operator":"AND","analyzer":"whitespace\_lowercase","boost":4}}}}},{"match":{  
"scientificName.ngram":{"query":"fossil","operator":"AND","analyzer":  
"whitespace\_lowercase","boost":5}}},{"match":{"scientificName.tokenized":{  
"query":"fossil","operator":"AND","analyzer":"whitespace\_lowercase","boost":  
6}}},{"match":{"name.ngram":{"query":"fossil","operator":"AND","analyzer":  
"whitespace\_lowercase","boost":7}}},{"match":{"name.tokenized":{"query":  
"fossil","operator":"AND","analyzer":"whitespace\_lowercase","boost":8}}},{  
"match":{"sku.ngram":{"query":"fossil","operator":"AND","analyzer":  
"whitespace\_lowercase","boost":9}}},{"match":{"sku.tokenized":{"query":  
"fossil","operator":"AND","analyzer":"whitespace\_lowercase","boost":10  
}}}]}},"from":0,"size":10}

As you see results is dependent on few fields..

sku.ngram,  
name.ngram,  
scientificName.tokenized  
etc

I need set some fields priority...  
For example first results will be that match sku.ngram, sku.tokenized then  
name.ngram, name.tokenized, scientificName etc...  
I need set up some priority to fields...

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6cbe0ff0-873a-4a64-ac18-04aaa2638068%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6cbe0ff0-873a-4a64-ac18-04aaa2638068%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Oleg\_Patrushev](https://avatars.discourse-cdn.com/v4/letter/o/22d042/32.png) [@Oleg\_Patrushev](https://discuss.elastic.co/u/Oleg_Patrushev)\
**Post date:** [March 2, 2015, 4:15pm UTC](https://discuss.elastic.co/t/how-to-sort-results-by-fields-priorities/22469/2 "2015-03-02T16:15:27Z")

</div>

Now results comes in undefined order..  
For example  
first few on scientificName match, then on name match, then sku, then  
metaKeywords etc

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0b638d10-b891-47b7-90db-4e9f58961019%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0b638d10-b891-47b7-90db-4e9f58961019%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:29am UTC](https://discuss.elastic.co/t/how-to-sort-results-by-fields-priorities/22469/3 "2017-07-06T00:29:05Z")

</div>


