# Sort by only '\_boost'

**URL:** <https://discuss.elastic.co/t/sort-by-only--boost/14459>\
**Category:** Elasticsearch\
**Created:** [November 19, 2013, 7:09am UTC](https://discuss.elastic.co/t/sort-by-only--boost/14459 "2013-11-19T07:09:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Min\_Cha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/min_cha/32/1131_2.png) [@Min\_Cha](https://discuss.elastic.co/u/Min_Cha)\
**Post date:** [November 19, 2013, 7:09am UTC](https://discuss.elastic.co/t/sort-by-only--boost/14459/1 "2013-11-19T07:09:54Z")

</div>

Hi all.  
I am implementing keyword search function. For this I have declared mapping  
as following.

{  
"fulltext":{  
"\_boost":{  
"name":"weight",  
"null\_value":1.0  
},  
"properties":{  
"musicId":{  
"type":"integer",  
"index":"not\_analyzed",  
"store":"true"  
},  
"title":{  
"type":"string",  
"index":"analyzed",  
"store":"true",  
"analyzer":"cjk"  
},  
"weight":{  
"type":"double",  
"index":"not\_analyzed",  
"store":"true"  
}  
}  
}  
}

Next, I have put as following docs.

musicId(1), title("あい"), weight(10)  
musicId(2), title("あいあい"), weight(20)  
musicId(3), title("あいあいあい"), weight(30)  
musicId(4), title("あいあいあいあい"), weight(40)

When, then, I searched by the keyword 'あい', output was as following.

musicId=2  
title=あいあい  
weight=20.0

musicId=3  
title=あいあいあい  
weight=30.0

musicId=4  
title=あいあいあいあい  
weight=40.0

musicId=1  
title=あい  
weight=10.0

I expected a doc that has higher boost value will be matched at top but it  
does not.  
Give me some advice please.

Thanks for reading.

--  
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:** ![Min\_Cha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/min_cha/32/1131_2.png) [@Min\_Cha](https://discuss.elastic.co/u/Min_Cha)\
**Post date:** [November 21, 2013, 1:52am UTC](https://discuss.elastic.co/t/sort-by-only--boost/14459/2 "2013-11-21T01:52:44Z")

</div>

Does anyone have some ideas?

2013년 11월 19일 화요일 오후 4시 9분 54초 UTC+9, Min Cha 님의 말:

> Hi all.  
> I am implementing keyword search function. For this I have declared  
> mapping as following.
> 
> {  
> "fulltext":{  
> "\_boost":{  
> "name":"weight",  
> "null\_value":1.0  
> },  
> "properties":{  
> "musicId":{  
> "type":"integer",  
> "index":"not\_analyzed",  
> "store":"true"  
> },  
> "title":{  
> "type":"string",  
> "index":"analyzed",  
> "store":"true",  
> "analyzer":"cjk"  
> },  
> "weight":{  
> "type":"double",  
> "index":"not\_analyzed",  
> "store":"true"  
> }  
> }  
> }  
> }
> 
> Next, I have put as following docs.
> 
> musicId(1), title("あい"), weight(10)  
> musicId(2), title("あいあい"), weight(20)  
> musicId(3), title("あいあいあい"), weight(30)  
> musicId(4), title("あいあいあいあい"), weight(40)
> 
> When, then, I searched by the keyword 'あい', output was as following.
> 
> musicId=2  
> title=あいあい  
> weight=20.0
> 
> musicId=3  
> title=あいあいあい  
> weight=30.0
> 
> musicId=4  
> title=あいあいあいあい  
> weight=40.0
> 
> musicId=1  
> title=あい  
> weight=10.0
> 
> I expected a doc that has higher boost value will be matched at top but it  
> does not.  
> Give me some advice please.
> 
> Thanks for reading.

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 21, 2013, 5:53am UTC](https://discuss.elastic.co/t/sort-by-only--boost/14459/3 "2013-11-21T05:53:47Z")

</div>

Try to add explain: true to your query to see how score is computed.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 nov. 2013 à 02:52, Min Cha [minslovey@gmail.com](mailto:minslovey@gmail.com) a écrit :

Does anyone have some ideas?

2013년 11월 19일 화요일 오후 4시 9분 54초 UTC+9, Min Cha 님의 말:

> Hi all.  
> I am implementing keyword search function. For this I have declared mapping as following.
> 
> {  
> "fulltext":{  
> "\_boost":{  
> "name":"weight",  
> "null\_value":1.0  
> },  
> "properties":{  
> "musicId":{  
> "type":"integer",  
> "index":"not\_analyzed",  
> "store":"true"  
> },  
> "title":{  
> "type":"string",  
> "index":"analyzed",  
> "store":"true",  
> "analyzer":"cjk"  
> },  
> "weight":{  
> "type":"double",  
> "index":"not\_analyzed",  
> "store":"true"  
> }  
> }  
> }  
> }
> 
> Next, I have put as following docs.
> 
> musicId(1), title("あい"), weight(10)  
> musicId(2), title("あいあい"), weight(20)  
> musicId(3), title("あいあいあい"), weight(30)  
> musicId(4), title("あいあいあいあい"), weight(40)
> 
> When, then, I searched by the keyword 'あい', output was as following.
> 
> musicId=2  
> title=あいあい  
> weight=20.0
> 
> musicId=3  
> title=あいあいあい  
> weight=30.0
> 
> musicId=4  
> title=あいあいあいあい  
> weight=40.0
> 
> musicId=1  
> title=あい  
> weight=10.0
> 
> I expected a doc that has higher boost value will be matched at top but it does not.  
> Give me some advice please.
> 
> Thanks for reading.

--  
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).

--  
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:** ![Min\_Cha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/min_cha/32/1131_2.png) [@Min\_Cha](https://discuss.elastic.co/u/Min_Cha)\
**Post date:** [December 4, 2013, 9:44am UTC](https://discuss.elastic.co/t/sort-by-only--boost/14459/4 "2013-12-04T09:44:51Z")

</div>

[https://groups.google.com/forum/?fromgroups#!searchin/elasticsearch/Min$20Cha|sort:date/elasticsearch/39L7hXJR8GY/gRJRiiASat0J](https://groups.google.com/forum/?fromgroups#!searchin/elasticsearch/Min$20Cha%7Csort:date/elasticsearch/39L7hXJR8GY/gRJRiiASat0J)

ES supports custom score script so if I wants to sort only \_boost value, I  
can use script as "source.\_boost" in script.  
It`s simple and works fine.

Example : {"query":{"custom\_score":{"query":{"query\_string":{"  
query":"title:"Love""}},"script":"\_source.boost"}}}

2013년 11월 19일 화요일 오후 4시 9분 54초 UTC+9, Min Cha 님의 말:

> Hi all.  
> I am implementing keyword search function. For this I have declared  
> mapping as following.
> 
> {  
> "fulltext":{  
> "\_boost":{  
> "name":"weight",  
> "null\_value":1.0  
> },  
> "properties":{  
> "musicId":{  
> "type":"integer",  
> "index":"not\_analyzed",  
> "store":"true"  
> },  
> "title":{  
> "type":"string",  
> "index":"analyzed",  
> "store":"true",  
> "analyzer":"cjk"  
> },  
> "weight":{  
> "type":"double",  
> "index":"not\_analyzed",  
> "store":"true"  
> }  
> }  
> }  
> }
> 
> Next, I have put as following docs.
> 
> musicId(1), title("あい"), weight(10)  
> musicId(2), title("あいあい"), weight(20)  
> musicId(3), title("あいあいあい"), weight(30)  
> musicId(4), title("あいあいあいあい"), weight(40)
> 
> When, then, I searched by the keyword 'あい', output was as following.
> 
> musicId=2  
> title=あいあい  
> weight=20.0
> 
> musicId=3  
> title=あいあいあい  
> weight=30.0
> 
> musicId=4  
> title=あいあいあいあい  
> weight=40.0
> 
> musicId=1  
> title=あい  
> weight=10.0
> 
> I expected a doc that has higher boost value will be matched at top but it  
> does not.  
> Give me some advice please.
> 
> Thanks for reading.

--  
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/96e85231-6341-4919-adc8-af0273824777%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/96e85231-6341-4919-adc8-af0273824777%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [December 4, 2013, 3:28pm UTC](https://discuss.elastic.co/t/sort-by-only--boost/14459/5 "2013-12-04T15:28:17Z")

</div>

Why not simply sort on the weight field?

--  
Ivan

On Wed, Dec 4, 2013 at 1:44 AM, Min Cha [minslovey@gmail.com](mailto:minslovey@gmail.com) wrote:

> [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups#!searchin/elasticsearch/Min$20Cha%7Csort:date/elasticsearch/39L7hXJR8GY/gRJRiiASat0J)
> 
> ES supports custom score script so if I wants to sort only \_boost value, I  
> can use script as "source.\_boost" in script.  
> It`s simple and works fine.
> 
> Example : {"query":{"custom\_score":{"query":{"query\_string":{"  
> query":"title:"Love""}},"script":"\_source.boost"}}}
> 
> 2013년 11월 19일 화요일 오후 4시 9분 54초 UTC+9, Min Cha 님의 말:
> 
> > Hi all.  
> > I am implementing keyword search function. For this I have declared  
> > mapping as following.
> > 
> > {  
> > "fulltext":{  
> > "\_boost":{  
> > "name":"weight",  
> > "null\_value":1.0  
> > },  
> > "properties":{  
> > "musicId":{  
> > "type":"integer",  
> > "index":"not\_analyzed",  
> > "store":"true"  
> > },  
> > "title":{  
> > "type":"string",  
> > "index":"analyzed",  
> > "store":"true",  
> > "analyzer":"cjk"  
> > },  
> > "weight":{  
> > "type":"double",  
> > "index":"not\_analyzed",  
> > "store":"true"  
> > }  
> > }  
> > }  
> > }
> > 
> > Next, I have put as following docs.
> > 
> > musicId(1), title("あい"), weight(10)  
> > musicId(2), title("あいあい"), weight(20)  
> > musicId(3), title("あいあいあい"), weight(30)  
> > musicId(4), title("あいあいあいあい"), weight(40)
> > 
> > When, then, I searched by the keyword 'あい', output was as following.
> > 
> > musicId=2  
> > title=あいあい  
> > weight=20.0
> > 
> > musicId=3  
> > title=あいあいあい  
> > weight=30.0
> > 
> > musicId=4  
> > title=あいあいあいあい  
> > weight=40.0
> > 
> > musicId=1  
> > title=あい  
> > weight=10.0
> > 
> > I expected a doc that has higher boost value will be matched at top but  
> > it does not.  
> > Give me some advice please.
> > 
> > Thanks for reading.
> > 
> > --  
> > 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/96e85231-6341-4919-adc8-af0273824777%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/96e85231-6341-4919-adc8-af0273824777%40googlegroups.com)  
> > .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/CALY%3DcQC1A0M7kS\_YLsLYH3\_%2B9X477XuHdkODyiP7Y\_zsOYXWxw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQC1A0M7kS_YLsLYH3_%2B9X477XuHdkODyiP7Y_zsOYXWxw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Min\_Cha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/min_cha/32/1131_2.png) [@Min\_Cha](https://discuss.elastic.co/u/Min_Cha)\
**Post date:** [December 5, 2013, 9:06am UTC](https://discuss.elastic.co/t/sort-by-only--boost/14459/6 "2013-12-05T09:06:03Z")

</div>

You are right. Sort looks like better than custom score when simply  
ordering by a field.

2013년 12월 5일 목요일 오전 12시 28분 17초 UTC+9, Ivan Brusic 님의 말:

> Why not simply sort on the weight field?
> 
> --  
> Ivan
> 
> On Wed, Dec 4, 2013 at 1:44 AM, Min Cha \<[mins...@gmail.com](mailto:mins...@gmail.com) \<javascript:\>\>wrote:
> 
> > [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups#!searchin/elasticsearch/Min$20Cha%7Csort:date/elasticsearch/39L7hXJR8GY/gRJRiiASat0J)
> > 
> > ES supports custom score script so if I wants to sort only \_boost value,  
> > I can use script as "source.\_boost" in script.  
> > It`s simple and works fine.
> > 
> > Example : {"query":{"custom\_score":{"query":{"query\_string":{"  
> > query":"title:"Love""}},"script":"\_source.boost"}}}
> > 
> > 2013년 11월 19일 화요일 오후 4시 9분 54초 UTC+9, Min Cha 님의 말:
> > 
> > > Hi all.  
> > > I am implementing keyword search function. For this I have declared  
> > > mapping as following.
> > > 
> > > {  
> > > "fulltext":{  
> > > "\_boost":{  
> > > "name":"weight",  
> > > "null\_value":1.0  
> > > },  
> > > "properties":{  
> > > "musicId":{  
> > > "type":"integer",  
> > > "index":"not\_analyzed",  
> > > "store":"true"  
> > > },  
> > > "title":{  
> > > "type":"string",  
> > > "index":"analyzed",  
> > > "store":"true",  
> > > "analyzer":"cjk"  
> > > },  
> > > "weight":{  
> > > "type":"double",  
> > > "index":"not\_analyzed",  
> > > "store":"true"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Next, I have put as following docs.
> > > 
> > > musicId(1), title("あい"), weight(10)  
> > > musicId(2), title("あいあい"), weight(20)  
> > > musicId(3), title("あいあいあい"), weight(30)  
> > > musicId(4), title("あいあいあいあい"), weight(40)
> > > 
> > > When, then, I searched by the keyword 'あい', output was as following.
> > > 
> > > musicId=2  
> > > title=あいあい  
> > > weight=20.0
> > > 
> > > musicId=3  
> > > title=あいあいあい  
> > > weight=30.0
> > > 
> > > musicId=4  
> > > title=あいあいあいあい  
> > > weight=40.0
> > > 
> > > musicId=1  
> > > title=あい  
> > > weight=10.0
> > > 
> > > I expected a doc that has higher boost value will be matched at top but  
> > > it does not.  
> > > Give me some advice please.
> > > 
> > > Thanks for reading.
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/96e85231-6341-4919-adc8-af0273824777%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/96e85231-6341-4919-adc8-af0273824777%40googlegroups.com)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/d74752f0-81f6-4e2a-9a6d-665d0321cc76%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d74752f0-81f6-4e2a-9a6d-665d0321cc76%40googlegroups.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:03am UTC](https://discuss.elastic.co/t/sort-by-only--boost/14459/7 "2017-07-06T02:03:09Z")

</div>


