# Why aren't my string \_boost values sorting correctly?

**URL:** <https://discuss.elastic.co/t/why-arent-my-string--boost-values-sorting-correctly/10678>\
**Category:** Elasticsearch\
**Created:** [February 9, 2013, 7:21am UTC](https://discuss.elastic.co/t/why-arent-my-string--boost-values-sorting-correctly/10678 "2013-02-09T07:21:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jade\_Dominguez](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@Jade\_Dominguez](https://discuss.elastic.co/u/Jade_Dominguez)\
**Post date:** [February 9, 2013, 7:21am UTC](https://discuss.elastic.co/t/why-arent-my-string--boost-values-sorting-correctly/10678/1 "2013-02-09T07:21:36Z")

</div>

Below is my complete curl recreation. I expect the \_boost values to sort  
the documents nicely from 5 to 1. However I get inconsistent results. If i  
run this recreation 10 times, I will get a variety of sort orders! Mostly  
out of order, sometimes in order etc, but why the inconsistency?

I understand that many factors contribute to the score, not just \_boost,  
but all these documents are near identical right? How would term frequency  
or document length skew the scoring if the docs are the same?

My goal is to index many terms inside the skills field (hence the array) so  
I cannot simply move the boost to the document level. I need the boost to  
be on a specific term so when I search for that term the scoring should  
reflect that _specific term's_ boost value.

What am I doing wrong?

curl -XDELETE '[http://localhost:9200/p](http://localhost:9200/p)'  
curl -XPOST '[http://localhost:9200/p](http://localhost:9200/p)'

curl -XPOST 'localhost:9200/p/profile/\_mapping' -d '  
{  
"profile": {  
"properties": {  
"skills": {  
"type": "string",  
"omit\_term\_freq\_and\_positions" : true,  
"index" : "not\_analyzed"  
}  
}  
}  
}'

curl -XPOST localhost:9200/p/profile -d '{  
"skills": [{ "\_value": "ruby", "\_boost": 5 }]  
}'  
curl -XPOST localhost:9200/p/profile -d '{  
"skills": [{ "\_value": "ruby", "\_boost": 4 }]  
}'  
curl -XPOST localhost:9200/p/profile -d '{  
"skills": [{ "\_value": "ruby", "\_boost": 1 }]  
}'  
curl -XPOST localhost:9200/p/profile -d '{  
"skills": [{ "\_value": "ruby", "\_boost": 3 }]  
}'  
curl -XPOST localhost:9200/p/profile -d '{  
"skills": [{ "\_value": "ruby", "\_boost": 2 }]  
}'  
curl -XPOST localhost:9200/p/profile -d '{  
"skills": [{ "\_value": "python", "\_boost": 100 }]  
}'

curl -XPOST "[http://localhost:9200/p/\_refresh](http://localhost:9200/p/_refresh)"

curl -XGET 'localhost:9200/p/\_search?pretty=true' -d '{  
"query": {  
"query\_string": {  
"query": "ruby"  
}  
},  
"sort": [{"\_score": "desc"}],  
"explain": true  
}'

----------------------- OUTPUT -----------------------

{  
"took" : 22,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 5,  
"max\_score" : 2.828427,  
"hits" : [ {  
"\_shard" : 3,  
"\_node" : "eunz7yXoQvKYGfCbAsltYw",  
"\_index" : "p",  
"\_type" : "profile",  
"\_id" : "2JV5NJYOQoSgUr59XulocA",  
"\_score" : 2.828427, "\_source" : {  
"skills": [{ "\_value": "ruby", "\_boost": 4 }]  
},  
"\_explanation" : {  
"value" : 2.828427,  
"description" : "fieldWeight(\_all:ruby in 0), product of:",  
"details" : [ {  
"value" : 2.828427,  
"description" : "btq, product of:",  
"details" : [ {  
"value" : 0.70710677,  
"description" : "tf(phraseFreq=0.5)"  
}, {  
"value" : 4.0,  
"description" : "allPayload(...)"  
} ]  
}, {  
"value" : 1.0,  
"description" : "idf(\_all: ruby=2)"  
}, {  
"value" : 1.0,  
"description" : "fieldNorm(field=\_all, doc=0)"  
} ]  
}  
}, {  
"\_shard" : 4,  
"\_node" : "eunz7yXoQvKYGfCbAsltYw",  
"\_index" : "p",  
"\_type" : "profile",  
"\_id" : "fuMfbcDcRTqEp3GGSmtUlA",  
"\_score" : 2.101998, "\_source" : {  
"skills": [{ "\_value": "ruby", "\_boost": 5 }]  
},  
"\_explanation" : {  
"value" : 2.1019979,  
"description" : "weight(\_all:ruby in 0), product of:",  
"details" : [ {  
"value" : 0.99999994,  
"description" : "queryWeight(\_all:ruby), product of:",  
"details" : [ {  
"value" : 0.5945349,  
"description" : "idf(\_all: ruby=2)"  
}, {  
"value" : 1.681987,  
"description" : "queryNorm"  
} ]  
}, {  
"value" : 2.101998,  
"description" : "fieldWeight(\_all:ruby in 0), product of:",  
"details" : [ {  
"value" : 3.535534,  
"description" : "btq, product of:",  
"details" : [ {  
"value" : 0.70710677,  
"description" : "tf(phraseFreq=0.5)"  
}, {  
"value" : 5.0,  
"description" : "allPayload(...)"  
} ]  
}, {  
"value" : 0.5945349,  
"description" : "idf(\_all: ruby=2)"  
}, {  
"value" : 1.0,  
"description" : "fieldNorm(field=\_all, doc=0)"  
} ]  
} ]  
}  
}, {  
"\_shard" : 4,  
"\_node" : "eunz7yXoQvKYGfCbAsltYw",  
"\_index" : "p",  
"\_type" : "profile",  
"\_id" : "GSrNarYwSSm99RPx\_XCfSA",  
"\_score" : 1.2611988, "\_source" : {  
"skills": [{ "\_value": "ruby", "\_boost": 3 }]  
},  
"\_explanation" : {  
"value" : 1.2611988,  
"description" : "weight(\_all:ruby in 1), product of:",  
"details" : [ {  
"value" : 0.99999994,  
"description" : "queryWeight(\_all:ruby), product of:",  
"details" : [ {  
"value" : 0.5945349,  
"description" : "idf(\_all: ruby=2)"  
}, {  
"value" : 1.681987,  
"description" : "queryNorm"  
} ]  
}, {  
"value" : 1.2611989,  
"description" : "fieldWeight(\_all:ruby in 1), product of:",  
"details" : [ {  
"value" : 2.1213202,  
"description" : "btq, product of:",  
"details" : [ {  
"value" : 0.70710677,  
"description" : "tf(phraseFreq=0.5)"  
}, {  
"value" : 3.0,  
"description" : "allPayload(...)"  
} ]  
}, {  
"value" : 0.5945349,  
"description" : "idf(\_all: ruby=2)"  
}, {  
"value" : 1.0,  
"description" : "fieldNorm(field=\_all, doc=1)"  
} ]  
} ]  
}  
}, {  
"\_shard" : 3,  
"\_node" : "eunz7yXoQvKYGfCbAsltYw",  
"\_index" : "p",  
"\_type" : "profile",  
"\_id" : "L5LiRwf7Tr67KAwiz6Rrig",  
"\_score" : 0.70710677, "\_source" : {  
"skills": [{ "\_value": "ruby", "\_boost": 1 }]  
},  
"\_explanation" : {  
"value" : 0.70710677,  
"description" : "fieldWeight(\_all:ruby in 1), product of:",  
"details" : [ {  
"value" : 0.70710677,  
"description" : "btq, product of:",  
"details" : [ {  
"value" : 0.70710677,  
"description" : "tf(phraseFreq=0.5)"  
}, {  
"value" : 1.0,  
"description" : "allPayload(...)"  
} ]  
}, {  
"value" : 1.0,  
"description" : "idf(\_all: ruby=2)"  
}, {  
"value" : 1.0,  
"description" : "fieldNorm(field=\_all, doc=1)"  
} ]  
}  
}, {  
"\_shard" : 0,  
"\_node" : "eunz7yXoQvKYGfCbAsltYw",  
"\_index" : "p",  
"\_type" : "profile",  
"\_id" : "PNx2hHtVShq4ZJbQAEKqaA",  
"\_score" : 0.4339554, "\_source" : {  
"skills": [{ "\_value": "ruby", "\_boost": 2 }]  
},  
"\_explanation" : {  
"value" : 0.4339554,  
"description" : "fieldWeight(\_all:ruby in 0), product of:",  
"details" : [ {  
"value" : 1.4142135,  
"description" : "btq, product of:",  
"details" : [ {  
"value" : 0.70710677,  
"description" : "tf(phraseFreq=0.5)"  
}, {  
"value" : 2.0,  
"description" : "allPayload(...)"  
} ]  
}, {  
"value" : 0.30685282,  
"description" : "idf(\_all: ruby=1)"  
}, {  
"value" : 1.0,  
"description" : "fieldNorm(field=\_all, doc=0)"  
} ]  
}  
} ]  
}  
}

--  
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:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [February 11, 2013, 9:34am UTC](https://discuss.elastic.co/t/why-arent-my-string--boost-values-sorting-correctly/10678/2 "2013-02-11T09:34:41Z")

</div>

Hi Jade,

In the case you just index a few documents into an index, the documents  
tend to be unbalanced between shards,  
which I think happened here as well. What you can do to make your test pass  
is to set the query string parameter: `search_type=dfs_query_then_fetch`  
in your search request. This enables a distributed document frequency phase  
before the actual query is executed and makes sure that for the idf factor  
cross shard frequencies are taken into account.

Normally the default search\_type is fine, because usually enough data has  
been indexed and therefore the documents are more or less balanced between  
shards.

Martijn

On 9 February 2013 08:21, Jade Dominguez [superjadex12@gmail.com](mailto:superjadex12@gmail.com) wrote:

> Below is my complete curl recreation. I expect the \_boost values to sort  
> the documents nicely from 5 to 1. However I get inconsistent results. If i  
> run this recreation 10 times, I will get a variety of sort orders! Mostly  
> out of order, sometimes in order etc, but why the inconsistency?
> 
> I understand that many factors contribute to the score, not just \_boost,  
> but all these documents are near identical right? How would term frequency  
> or document length skew the scoring if the docs are the same?
> 
> My goal is to index many terms inside the skills field (hence the array)  
> so I cannot simply move the boost to the document level. I need the boost  
> to be on a specific term so when I search for that term the scoring should  
> reflect that _specific term's_ boost value.
> 
> What am I doing wrong?
> 
> curl -XDELETE '[http://localhost:9200/p](http://localhost:9200/p)'  
> curl -XPOST '[http://localhost:9200/p](http://localhost:9200/p)'
> 
> curl -XPOST 'localhost:9200/p/profile/\_mapping' -d '  
> {  
> "profile": {  
> "properties": {  
> "skills": {  
> "type": "string",  
> "omit\_term\_freq\_and\_positions" : true,  
> "index" : "not\_analyzed"  
> }  
> }  
> }  
> }'
> 
> curl -XPOST localhost:9200/p/profile -d '{  
> "skills": [{ "\_value": "ruby", "\_boost": 5 }]  
> }'  
> curl -XPOST localhost:9200/p/profile -d '{  
> "skills": [{ "\_value": "ruby", "\_boost": 4 }]  
> }'  
> curl -XPOST localhost:9200/p/profile -d '{  
> "skills": [{ "\_value": "ruby", "\_boost": 1 }]  
> }'  
> curl -XPOST localhost:9200/p/profile -d '{  
> "skills": [{ "\_value": "ruby", "\_boost": 3 }]  
> }'  
> curl -XPOST localhost:9200/p/profile -d '{  
> "skills": [{ "\_value": "ruby", "\_boost": 2 }]  
> }'  
> curl -XPOST localhost:9200/p/profile -d '{  
> "skills": [{ "\_value": "python", "\_boost": 100 }]  
> }'
> 
> curl -XPOST "[http://localhost:9200/p/\_refresh](http://localhost:9200/p/_refresh)"
> 
> curl -XGET 'localhost:9200/p/\_search?pretty=true' -d '{  
> "query": {  
> "query\_string": {  
> "query": "ruby"  
> }  
> },  
> "sort": [{"\_score": "desc"}],  
> "explain": true  
> }'
> 
> ----------------------- OUTPUT -----------------------
> 
> {  
> "took" : 22,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 5,  
> "max\_score" : 2.828427,  
> "hits" : [ {  
> "\_shard" : 3,  
> "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> "\_index" : "p",  
> "\_type" : "profile",  
> "\_id" : "2JV5NJYOQoSgUr59XulocA",  
> "\_score" : 2.828427, "\_source" : {  
> "skills": [{ "\_value": "ruby", "\_boost": 4 }]  
> },  
> "\_explanation" : {  
> "value" : 2.828427,  
> "description" : "fieldWeight(\_all:ruby in 0), product of:",  
> "details" : [ {  
> "value" : 2.828427,  
> "description" : "btq, product of:",  
> "details" : [ {  
> "value" : 0.70710677,  
> "description" : "tf(phraseFreq=0.5)"  
> }, {  
> "value" : 4.0,  
> "description" : "allPayload(...)"  
> } ]  
> }, {  
> "value" : 1.0,  
> "description" : "idf(\_all: ruby=2)"  
> }, {  
> "value" : 1.0,  
> "description" : "fieldNorm(field=\_all, doc=0)"  
> } ]  
> }  
> }, {  
> "\_shard" : 4,  
> "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> "\_index" : "p",  
> "\_type" : "profile",  
> "\_id" : "fuMfbcDcRTqEp3GGSmtUlA",  
> "\_score" : 2.101998, "\_source" : {  
> "skills": [{ "\_value": "ruby", "\_boost": 5 }]  
> },  
> "\_explanation" : {  
> "value" : 2.1019979,  
> "description" : "weight(\_all:ruby in 0), product of:",  
> "details" : [ {  
> "value" : 0.99999994,  
> "description" : "queryWeight(\_all:ruby), product of:",  
> "details" : [ {  
> "value" : 0.5945349,  
> "description" : "idf(\_all: ruby=2)"  
> }, {  
> "value" : 1.681987,  
> "description" : "queryNorm"  
> } ]  
> }, {  
> "value" : 2.101998,  
> "description" : "fieldWeight(\_all:ruby in 0), product of:",  
> "details" : [ {  
> "value" : 3.535534,  
> "description" : "btq, product of:",  
> "details" : [ {  
> "value" : 0.70710677,  
> "description" : "tf(phraseFreq=0.5)"  
> }, {  
> "value" : 5.0,  
> "description" : "allPayload(...)"  
> } ]  
> }, {  
> "value" : 0.5945349,  
> "description" : "idf(\_all: ruby=2)"  
> }, {  
> "value" : 1.0,  
> "description" : "fieldNorm(field=\_all, doc=0)"  
> } ]  
> } ]  
> }  
> }, {  
> "\_shard" : 4,  
> "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> "\_index" : "p",  
> "\_type" : "profile",  
> "\_id" : "GSrNarYwSSm99RPx\_XCfSA",  
> "\_score" : 1.2611988, "\_source" : {  
> "skills": [{ "\_value": "ruby", "\_boost": 3 }]  
> },  
> "\_explanation" : {  
> "value" : 1.2611988,  
> "description" : "weight(\_all:ruby in 1), product of:",  
> "details" : [ {  
> "value" : 0.99999994,  
> "description" : "queryWeight(\_all:ruby), product of:",  
> "details" : [ {  
> "value" : 0.5945349,  
> "description" : "idf(\_all: ruby=2)"  
> }, {  
> "value" : 1.681987,  
> "description" : "queryNorm"  
> } ]  
> }, {  
> "value" : 1.2611989,  
> "description" : "fieldWeight(\_all:ruby in 1), product of:",  
> "details" : [ {  
> "value" : 2.1213202,  
> "description" : "btq, product of:",  
> "details" : [ {  
> "value" : 0.70710677,  
> "description" : "tf(phraseFreq=0.5)"  
> }, {  
> "value" : 3.0,  
> "description" : "allPayload(...)"  
> } ]  
> }, {  
> "value" : 0.5945349,  
> "description" : "idf(\_all: ruby=2)"  
> }, {  
> "value" : 1.0,  
> "description" : "fieldNorm(field=\_all, doc=1)"  
> } ]  
> } ]  
> }  
> }, {  
> "\_shard" : 3,  
> "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> "\_index" : "p",  
> "\_type" : "profile",  
> "\_id" : "L5LiRwf7Tr67KAwiz6Rrig",  
> "\_score" : 0.70710677, "\_source" : {  
> "skills": [{ "\_value": "ruby", "\_boost": 1 }]  
> },  
> "\_explanation" : {  
> "value" : 0.70710677,  
> "description" : "fieldWeight(\_all:ruby in 1), product of:",  
> "details" : [ {  
> "value" : 0.70710677,  
> "description" : "btq, product of:",  
> "details" : [ {  
> "value" : 0.70710677,  
> "description" : "tf(phraseFreq=0.5)"  
> }, {  
> "value" : 1.0,  
> "description" : "allPayload(...)"  
> } ]  
> }, {  
> "value" : 1.0,  
> "description" : "idf(\_all: ruby=2)"  
> }, {  
> "value" : 1.0,  
> "description" : "fieldNorm(field=\_all, doc=1)"  
> } ]  
> }  
> }, {  
> "\_shard" : 0,  
> "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> "\_index" : "p",  
> "\_type" : "profile",  
> "\_id" : "PNx2hHtVShq4ZJbQAEKqaA",  
> "\_score" : 0.4339554, "\_source" : {  
> "skills": [{ "\_value": "ruby", "\_boost": 2 }]  
> },  
> "\_explanation" : {  
> "value" : 0.4339554,  
> "description" : "fieldWeight(\_all:ruby in 0), product of:",  
> "details" : [ {  
> "value" : 1.4142135,  
> "description" : "btq, product of:",  
> "details" : [ {  
> "value" : 0.70710677,  
> "description" : "tf(phraseFreq=0.5)"  
> }, {  
> "value" : 2.0,  
> "description" : "allPayload(...)"  
> } ]  
> }, {  
> "value" : 0.30685282,  
> "description" : "idf(\_all: ruby=1)"  
> }, {  
> "value" : 1.0,  
> "description" : "fieldNorm(field=\_all, doc=0)"  
> } ]  
> }  
> } ]  
> }  
> }
> 
> --  
> 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).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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:** ![Jade\_Dominguez](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@Jade\_Dominguez](https://discuss.elastic.co/u/Jade_Dominguez)\
**Post date:** [February 11, 2013, 6:11pm UTC](https://discuss.elastic.co/t/why-arent-my-string--boost-values-sorting-correctly/10678/3 "2013-02-11T18:11:31Z")

</div>

Martijn, this is great, thank you! It works =)

Your answer makes very logical sense.

Here is the documentation on search types and my working search query to  
officially answer this question:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Parameter value: dfs\_query\_then\_fetch.

> Same as “Query Then Fetch”, except for an initial scatter phase which goes  
> and computes the distributed term frequencies for more accurate scoring.

curl -XGET  
'localhost:9200/p/\_search?&search\_type=dfs\_query\_then\_fetch&pretty=true' -d  
'{  
"query": {  
"query\_string": {  
"query": "ruby"  
}  
},  
"sort": [{"\_score": "desc"}],  
"explain": true  
}'

Thank you for your help!

- Jade

On Monday, February 11, 2013 1:34:41 AM UTC-8, Martijn v Groningen wrote:

> Hi Jade,
> 
> In the case you just index a few documents into an index, the documents  
> tend to be unbalanced between shards,  
> which I think happened here as well. What you can do to make your test  
> pass is to set the query string parameter:  
> `search_type=dfs_query_then_fetch`  
> in your search request. This enables a distributed document frequency  
> phase before the actual query is executed and makes sure that for the idf  
> factor cross shard frequencies are taken into account.
> 
> Normally the default search\_type is fine, because usually enough data has  
> been indexed and therefore the documents are more or less balanced between  
> shards.
> 
> Martijn
> 
> On 9 February 2013 08:21, Jade Dominguez \<[superj...@gmail.com](mailto:superj...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Below is my complete curl recreation. I expect the \_boost values to sort  
> > the documents nicely from 5 to 1. However I get inconsistent results. If i  
> > run this recreation 10 times, I will get a variety of sort orders! Mostly  
> > out of order, sometimes in order etc, but why the inconsistency?
> > 
> > I understand that many factors contribute to the score, not just \_boost,  
> > but all these documents are near identical right? How would term frequency  
> > or document length skew the scoring if the docs are the same?
> > 
> > My goal is to index many terms inside the skills field (hence the array)  
> > so I cannot simply move the boost to the document level. I need the boost  
> > to be on a specific term so when I search for that term the scoring should  
> > reflect that _specific term's_ boost value.
> > 
> > What am I doing wrong?
> > 
> > curl -XDELETE '[http://localhost:9200/p](http://localhost:9200/p)'  
> > curl -XPOST '[http://localhost:9200/p](http://localhost:9200/p)'
> > 
> > curl -XPOST 'localhost:9200/p/profile/\_mapping' -d '  
> > {  
> > "profile": {  
> > "properties": {  
> > "skills": {  
> > "type": "string",  
> > "omit\_term\_freq\_and\_positions" : true,  
> > "index" : "not\_analyzed"  
> > }  
> > }  
> > }  
> > }'
> > 
> > curl -XPOST localhost:9200/p/profile -d '{  
> > "skills": [{ "\_value": "ruby", "\_boost": 5 }]  
> > }'  
> > curl -XPOST localhost:9200/p/profile -d '{  
> > "skills": [{ "\_value": "ruby", "\_boost": 4 }]  
> > }'  
> > curl -XPOST localhost:9200/p/profile -d '{  
> > "skills": [{ "\_value": "ruby", "\_boost": 1 }]  
> > }'  
> > curl -XPOST localhost:9200/p/profile -d '{  
> > "skills": [{ "\_value": "ruby", "\_boost": 3 }]  
> > }'  
> > curl -XPOST localhost:9200/p/profile -d '{  
> > "skills": [{ "\_value": "ruby", "\_boost": 2 }]  
> > }'  
> > curl -XPOST localhost:9200/p/profile -d '{  
> > "skills": [{ "\_value": "python", "\_boost": 100 }]  
> > }'
> > 
> > curl -XPOST "[http://localhost:9200/p/\_refresh](http://localhost:9200/p/_refresh)"
> > 
> > curl -XGET 'localhost:9200/p/\_search?pretty=true' -d '{  
> > "query": {  
> > "query\_string": {  
> > "query": "ruby"  
> > }  
> > },  
> > "sort": [{"\_score": "desc"}],  
> > "explain": true  
> > }'
> > 
> > ----------------------- OUTPUT -----------------------
> > 
> > {  
> > "took" : 22,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 5,  
> > "max\_score" : 2.828427,  
> > "hits" : [ {  
> > "\_shard" : 3,  
> > "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> > "\_index" : "p",  
> > "\_type" : "profile",  
> > "\_id" : "2JV5NJYOQoSgUr59XulocA",  
> > "\_score" : 2.828427, "\_source" : {  
> > "skills": [{ "\_value": "ruby", "\_boost": 4 }]  
> > },  
> > "\_explanation" : {  
> > "value" : 2.828427,  
> > "description" : "fieldWeight(\_all:ruby in 0), product of:",  
> > "details" : [ {  
> > "value" : 2.828427,  
> > "description" : "btq, product of:",  
> > "details" : [ {  
> > "value" : 0.70710677,  
> > "description" : "tf(phraseFreq=0.5)"  
> > }, {  
> > "value" : 4.0,  
> > "description" : "allPayload(...)"  
> > } ]  
> > }, {  
> > "value" : 1.0,  
> > "description" : "idf(\_all: ruby=2)"  
> > }, {  
> > "value" : 1.0,  
> > "description" : "fieldNorm(field=\_all, doc=0)"  
> > } ]  
> > }  
> > }, {  
> > "\_shard" : 4,  
> > "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> > "\_index" : "p",  
> > "\_type" : "profile",  
> > "\_id" : "fuMfbcDcRTqEp3GGSmtUlA",  
> > "\_score" : 2.101998, "\_source" : {  
> > "skills": [{ "\_value": "ruby", "\_boost": 5 }]  
> > },  
> > "\_explanation" : {  
> > "value" : 2.1019979,  
> > "description" : "weight(\_all:ruby in 0), product of:",  
> > "details" : [ {  
> > "value" : 0.99999994,  
> > "description" : "queryWeight(\_all:ruby), product of:",  
> > "details" : [ {  
> > "value" : 0.5945349,  
> > "description" : "idf(\_all: ruby=2)"  
> > }, {  
> > "value" : 1.681987,  
> > "description" : "queryNorm"  
> > } ]  
> > }, {  
> > "value" : 2.101998,  
> > "description" : "fieldWeight(\_all:ruby in 0), product of:",  
> > "details" : [ {  
> > "value" : 3.535534,  
> > "description" : "btq, product of:",  
> > "details" : [ {  
> > "value" : 0.70710677,  
> > "description" : "tf(phraseFreq=0.5)"  
> > }, {  
> > "value" : 5.0,  
> > "description" : "allPayload(...)"  
> > } ]  
> > }, {  
> > "value" : 0.5945349,  
> > "description" : "idf(\_all: ruby=2)"  
> > }, {  
> > "value" : 1.0,  
> > "description" : "fieldNorm(field=\_all, doc=0)"  
> > } ]  
> > } ]  
> > }  
> > }, {  
> > "\_shard" : 4,  
> > "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> > "\_index" : "p",  
> > "\_type" : "profile",  
> > "\_id" : "GSrNarYwSSm99RPx\_XCfSA",  
> > "\_score" : 1.2611988, "\_source" : {  
> > "skills": [{ "\_value": "ruby", "\_boost": 3 }]  
> > },  
> > "\_explanation" : {  
> > "value" : 1.2611988,  
> > "description" : "weight(\_all:ruby in 1), product of:",  
> > "details" : [ {  
> > "value" : 0.99999994,  
> > "description" : "queryWeight(\_all:ruby), product of:",  
> > "details" : [ {  
> > "value" : 0.5945349,  
> > "description" : "idf(\_all: ruby=2)"  
> > }, {  
> > "value" : 1.681987,  
> > "description" : "queryNorm"  
> > } ]  
> > }, {  
> > "value" : 1.2611989,  
> > "description" : "fieldWeight(\_all:ruby in 1), product of:",  
> > "details" : [ {  
> > "value" : 2.1213202,  
> > "description" : "btq, product of:",  
> > "details" : [ {  
> > "value" : 0.70710677,  
> > "description" : "tf(phraseFreq=0.5)"  
> > }, {  
> > "value" : 3.0,  
> > "description" : "allPayload(...)"  
> > } ]  
> > }, {  
> > "value" : 0.5945349,  
> > "description" : "idf(\_all: ruby=2)"  
> > }, {  
> > "value" : 1.0,  
> > "description" : "fieldNorm(field=\_all, doc=1)"  
> > } ]  
> > } ]  
> > }  
> > }, {  
> > "\_shard" : 3,  
> > "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> > "\_index" : "p",  
> > "\_type" : "profile",  
> > "\_id" : "L5LiRwf7Tr67KAwiz6Rrig",  
> > "\_score" : 0.70710677, "\_source" : {  
> > "skills": [{ "\_value": "ruby", "\_boost": 1 }]  
> > },  
> > "\_explanation" : {  
> > "value" : 0.70710677,  
> > "description" : "fieldWeight(\_all:ruby in 1), product of:",  
> > "details" : [ {  
> > "value" : 0.70710677,  
> > "description" : "btq, product of:",  
> > "details" : [ {  
> > "value" : 0.70710677,  
> > "description" : "tf(phraseFreq=0.5)"  
> > }, {  
> > "value" : 1.0,  
> > "description" : "allPayload(...)"  
> > } ]  
> > }, {  
> > "value" : 1.0,  
> > "description" : "idf(\_all: ruby=2)"  
> > }, {  
> > "value" : 1.0,  
> > "description" : "fieldNorm(field=\_all, doc=1)"  
> > } ]  
> > }  
> > }, {  
> > "\_shard" : 0,  
> > "\_node" : "eunz7yXoQvKYGfCbAsltYw",  
> > "\_index" : "p",  
> > "\_type" : "profile",  
> > "\_id" : "PNx2hHtVShq4ZJbQAEKqaA",  
> > "\_score" : 0.4339554, "\_source" : {  
> > "skills": [{ "\_value": "ruby", "\_boost": 2 }]  
> > },  
> > "\_explanation" : {  
> > "value" : 0.4339554,  
> > "description" : "fieldWeight(\_all:ruby in 0), product of:",  
> > "details" : [ {  
> > "value" : 1.4142135,  
> > "description" : "btq, product of:",  
> > "details" : [ {  
> > "value" : 0.70710677,  
> > "description" : "tf(phraseFreq=0.5)"  
> > }, {  
> > "value" : 2.0,  
> > "description" : "allPayload(...)"  
> > } ]  
> > }, {  
> > "value" : 0.30685282,  
> > "description" : "idf(\_all: ruby=1)"  
> > }, {  
> > "value" : 1.0,  
> > "description" : "fieldNorm(field=\_all, doc=0)"  
> > } ]  
> > }  
> > } ]  
> > }  
> > }
> > 
> > --  
> > 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:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Met vriendelijke groet,
> 
> Martijn van Groningen

--  
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:** ![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:52am UTC](https://discuss.elastic.co/t/why-arent-my-string--boost-values-sorting-correctly/10678/4 "2017-07-06T02:52:03Z")

</div>


