# Boosting a document value

**URL:** <https://discuss.elastic.co/t/boosting-a-document-value/10770>\
**Category:** Elasticsearch\
**Created:** [February 18, 2013, 11:04am UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770 "2013-02-18T11:04:09Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noam\_Guy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/noam_guy/32/2478_2.png) [@Noam\_Guy](https://discuss.elastic.co/u/Noam_Guy)\
**Post date:** [February 18, 2013, 11:04am UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/1 "2013-02-18T11:04:09Z")

</div>

Hi,

I know something like this was already answered but it's not what I need 🙂

I have two documents that look like this:

{  
"image" : {  
"lists" : [  
{  
"value" : "dior",  
"my\_boost" : "10"  
},  
{  
"value" : "red",  
"my\_boost" : "2"  
}  
]  
}  
}

{  
"image" : {  
"lists" : [  
{  
"value" : "dior",  
"my\_boost" : "2"  
},  
{  
"value" : "red",  
"my\_boost" : "10"  
}  
]  
}

If I search for "red" I will get these two documents.

BUT 🙂

I would like the query to use the my\_boost field to push the score higher  
for the relevant search

This means that I want the second document to be first (because it has a  
my\_boost=10).

I was thinking that custom\_score & script might help me - but I don't know  
how to accomplish it.

Any help will be appreciated.

Noam.

--  
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 18, 2013, 8:24pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/2 "2013-02-18T20:24:19Z")

</div>

You need to show us your mapping for the fields and also your query.

To my knowledge, the only way to use \_boost values on specific keywords is  
via the \_all field. (I'm not 100% sure but I've tried to make this work for  
a long time and the only success I've had is querying \_all field.)

[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/all-field.html). By  
default, all properties are copied over to the \_all field.

Next you must query on your \_all field. The easiest way to do that is to  
omit any field scoping from the query; this will default search the \_all  
field:

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

Notice I'm using dfs\_query\_then\_fetch [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/search-type.html).  
This will give you more accurate scoring that you will need.

There are other issues you will need to consider like if "red" is indexed  
anywhere else in the document, it means it will affect the term-frequencies  
and your ranking will be affected.

To receive better help, please post a complete curl  
recreation: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)

On Monday, February 18, 2013 3:04:09 AM UTC-8, Noam Guy wrote:

> Hi,
> 
> I know something like this was already answered but it's not what I need  
> 🙂
> 
> I have two documents that look like this:
> 
> {  
> "image" : {  
> "lists" : [  
> {  
> "value" : "dior",  
> "my\_boost" : "10"  
> },  
> {  
> "value" : "red",  
> "my\_boost" : "2"  
> }  
> ]  
> }  
> }
> 
> {  
> "image" : {  
> "lists" : [  
> {  
> "value" : "dior",  
> "my\_boost" : "2"  
> },  
> {  
> "value" : "red",  
> "my\_boost" : "10"  
> }  
> ]  
> }
> 
> If I search for "red" I will get these two documents.
> 
> BUT 🙂
> 
> I would like the query to use the my\_boost field to push the score higher  
> for the relevant search
> 
> This means that I want the second document to be first (because it has a  
> my\_boost=10).
> 
> I was thinking that custom\_score & script might help me - but I don't know  
> how to accomplish it.
> 
> Any help will be appreciated.
> 
> Noam.

--  
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:** ![AtoZ](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@AtoZ](https://discuss.elastic.co/u/AtoZ)\
**Post date:** [February 19, 2013, 1:44am UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/3 "2013-02-19T01:44:51Z")

</div>

We have the similar problem.

Here is our scenario:

We have a magazine DB. each magazine has a list of category tags, each tag  
has weight. Number of tags for each magazine is NOT fixed. The magazine doc  
also has name and attachment fileds.

When searching a keyword "sports",

if the keyword occurs in name filed, the document get boosted - we can use  
boost value for name field.  
if the keyword occurs in attachment, no extra boost.  
_if the keyword occurs in the tags, the document get boosted - we want to  
use the tag weight to boost the doc._

One possible solution I can imagine is using script and custom score and  
sort by cscore. However, as a newbie, I could not figure it out.

Appreciate for any help.

Allen

On Monday, February 18, 2013 6:04:09 AM UTC-5, Noam Guy wrote:

> Hi,
> 
> I know something like this was already answered but it's not what I need  
> 🙂
> 
> I have two documents that look like this:
> 
> {  
> "image" : {  
> "lists" : [  
> {  
> "value" : "dior",  
> "my\_boost" : "10"  
> },  
> {  
> "value" : "red",  
> "my\_boost" : "2"  
> }  
> ]  
> }  
> }
> 
> {  
> "image" : {  
> "lists" : [  
> {  
> "value" : "dior",  
> "my\_boost" : "2"  
> },  
> {  
> "value" : "red",  
> "my\_boost" : "10"  
> }  
> ]  
> }
> 
> If I search for "red" I will get these two documents.
> 
> BUT 🙂
> 
> I would like the query to use the my\_boost field to push the score higher  
> for the relevant search
> 
> This means that I want the second document to be first (because it has a  
> my\_boost=10).
> 
> I was thinking that custom\_score & script might help me - but I don't know  
> how to accomplish it.
> 
> Any help will be appreciated.
> 
> Noam.

--  
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:** ![Noam\_Guy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/noam_guy/32/2478_2.png) [@Noam\_Guy](https://discuss.elastic.co/u/Noam_Guy)\
**Post date:** [February 19, 2013, 7:20am UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/4 "2013-02-19T07:20:59Z")

</div>

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{  
"image" : {  
"properties" : {  
"lists" : {  
"properties" : {  
"value" : {"type" : "string"},  
"my\_boost" : {"type" : "string"}  
}  
}  
}  
}  
}

The problem (as I can see 🙂 ) from your solution is that it does not use  
the dynamic boost (my\_boost) I store when indexing the document.

Am I missing something?

Noam.

--  
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:** ![Noam\_Guy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/noam_guy/32/2478_2.png) [@Noam\_Guy](https://discuss.elastic.co/u/Noam_Guy)\
**Post date:** [February 19, 2013, 7:22am UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/5 "2013-02-19T07:22:09Z")

</div>

AtoZ - I feel that there is solution 🙂

Let's wait 🙂

Noam

--  
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 19, 2013, 6:41pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/6 "2013-02-19T18:41:12Z")

</div>

Noam, only \_boost, and boost are valid boost attribute keys. You cannot use  
an arbitrarily named value for boosting. The mapping you've shown is  
actually mapping an object with properties "value" and "my\_boost". You want  
to be mapping a string type with the value of "value" and the internal  
boost of \_boost:

{  
"message" : {  
"\_value": "boosted value",  
"\_boost": 2.0  
}  
}

Reference: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)  
(under type String)

I have made a control-test example to highlight boosting by individual  
keyword value: [Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. · GitHub](https://gist.github.com/plusjade/4988626)

Please verify you can run this and get back the expected results. Any  
further questions should build off this control test so that we are in  
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

> Hi Jade,
> 
> First of all thanks for the reply.
> 
> This is how the mapping should look like:
> 
> {  
> "image" : {  
> "properties" : {  
> "lists" : {  
> "properties" : {  
> "value" : {"type" : "string"},  
> "my\_boost" : {"type" : "string"}  
> }  
> }  
> }  
> }  
> }
> 
> The problem (as I can see 🙂 ) from your solution is that it does not use  
> the dynamic boost (my\_boost) I store when indexing the document.
> 
> Am I missing something?
> 
> Noam.

--  
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:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 19, 2013, 6:50pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/7 "2013-02-19T18:50:36Z")

</div>

The \_boost field is only for index-time boosts. Noam is looking for  
something like a "dynamic" boost, where the value used changes depending  
the the result.

IIRC, custom scorers do not work with nested fields, only parent fields.  
You might want to try a nested queries.

--

Ivan

On Tue, Feb 19, 2013 at 10:41 AM, Jade Dominguez [superjadex12@gmail.com](mailto:superjadex12@gmail.com)wrote:

> Noam, only \_boost, and boost are valid boost attribute keys. You cannot  
> use an arbitrarily named value for boosting. The mapping you've shown is  
> actually mapping an object with properties "value" and "my\_boost". You want  
> to be mapping a string type with the value of "value" and the internal  
> boost of \_boost:
> 
> {  
> "message" : {  
> "\_value": "boosted value",  
> "\_boost": 2.0  
> }  
> }
> 
> Reference:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)(under type String)
> 
> I have made a control-test example to highlight boosting by individual  
> keyword value: [Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. · GitHub](https://gist.github.com/plusjade/4988626)
> 
> Please verify you can run this and get back the expected results. Any  
> further questions should build off this control test so that we are in  
> complete alignment.
> 
> On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:
> 
> > Hi Jade,
> > 
> > First of all thanks for the reply.
> > 
> > This is how the mapping should look like:
> > 
> > {  
> > "image" : {  
> > "properties" : {  
> > "lists" : {  
> > "properties" : {  
> > "value" : {"type" : "string"},  
> > "my\_boost" : {"type" : "string"}  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > The problem (as I can see 🙂 ) from your solution is that it does not  
> > use the dynamic boost (my\_boost) I store when indexing the document.
> > 
> > Am I missing something?
> > 
> > Noam.
> > 
> > --  
> > 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:** ![Noam\_Guy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/noam_guy/32/2478_2.png) [@Noam\_Guy](https://discuss.elastic.co/u/Noam_Guy)\
**Post date:** [February 19, 2013, 8:47pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/8 "2013-02-19T20:47:25Z")

</div>

Hi Ivan,

You are right - I need a "dynamic" boost... (Jade - thank you any how..).  
Regarding the nested queries - can you give me an example (that uses a  
"dynamic" boost value) which I can learn from?

Thank you all 🙂

On Tuesday, February 19, 2013 8:50:36 PM UTC+2, Ivan Brusic wrote:

> The \_boost field is only for index-time boosts. Noam is looking for  
> something like a "dynamic" boost, where the value used changes depending  
> the the result.
> 
> IIRC, custom scorers do not work with nested fields, only parent fields.  
> You might want to try a nested queries.
> 
> --
> 
> Ivan
> 
> On Tue, Feb 19, 2013 at 10:41 AM, Jade Dominguez \<[superj...@gmail.com](mailto:superj...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Noam, only \_boost, and boost are valid boost attribute keys. You cannot  
> > use an arbitrarily named value for boosting. The mapping you've shown is  
> > actually mapping an object with properties "value" and "my\_boost". You want  
> > to be mapping a string type with the value of "value" and the internal  
> > boost of \_boost:
> > 
> > {  
> > "message" : {  
> > "\_value": "boosted value",  
> > "\_boost": 2.0  
> > }  
> > }
> > 
> > Reference:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)(under type String)
> > 
> > I have made a control-test example to highlight boosting by individual  
> > keyword value: [Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. · GitHub](https://gist.github.com/plusjade/4988626)
> > 
> > Please verify you can run this and get back the expected results. Any  
> > further questions should build off this control test so that we are in  
> > complete alignment.
> > 
> > On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:
> > 
> > > Hi Jade,
> > > 
> > > First of all thanks for the reply.
> > > 
> > > This is how the mapping should look like:
> > > 
> > > {  
> > > "image" : {
> > > 
> > > ```
> > > "properties" : {
> > > "lists" : {
> > > 
> > > "properties" : {
> > > 
> > > "value" : {"type" : "string"}, 
> > > 
> > > "my_boost" : {"type" : "string"}
> > > 
> > > }
> > > }
> > > 
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > The problem (as I can see 🙂 ) from your solution is that it does not  
> > > use the dynamic boost (my\_boost) I store when indexing the document.
> > > 
> > > Am I missing something?
> > > 
> > > Noam.
> > > 
> > > --  
> > > 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).

--  
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:** ![AtoZ](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@AtoZ](https://discuss.elastic.co/u/AtoZ)\
**Post date:** [February 20, 2013, 3:20am UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/9 "2013-02-20T03:20:22Z")

</div>

Hi Jade,

Thank you so much for your answer. I think I almost catch what I want

One more question: how multiple keyword boost value in a list impacts the  
document?

In my case, we will have a tag LIST. And some tags may contain same  
term/keyword:

Document 1:  
tag1: "sports", \_boost: 2,  
tag2: "winter sports", \_boost: 1.4,  
tag3: "tech": \_boost: 1.1,  
Content: "blah, blah, sports, blah, blan", \_boost: 1.0

Document 2:  
tag1: "sports", \_boost: 2,  
tag2: "blah music", \_boost: 1.5,  
tag3: "ent", \_boost: 1.3  
Content: "blah, blah, music, blah, blah", \_boost: 1.0

When I search keyword "sports" and sort it by \_score, I assume, document 1  
will be returned before document 2. How the \_score gets computed exactly?

Thanks a lot,

Allen

On Tuesday, February 19, 2013 1:41:12 PM UTC-5, Jade Dominguez wrote:

> Noam, only \_boost, and boost are valid boost attribute keys. You cannot  
> use an arbitrarily named value for boosting. The mapping you've shown is  
> actually mapping an object with properties "value" and "my\_boost". You want  
> to be mapping a string type with the value of "value" and the internal  
> boost of \_boost:
> 
> {  
> "message" : {  
> "\_value": "boosted value",  
> "\_boost": 2.0  
> }  
> }
> 
> Reference:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)(under type String)
> 
> I have made a control-test example to highlight boosting by individual  
> keyword value: [Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. · GitHub](https://gist.github.com/plusjade/4988626)
> 
> Please verify you can run this and get back the expected results. Any  
> further questions should build off this control test so that we are in  
> complete alignment.
> 
> On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:
> 
> > Hi Jade,
> > 
> > First of all thanks for the reply.
> > 
> > This is how the mapping should look like:
> > 
> > {  
> > "image" : {  
> > "properties" : {  
> > "lists" : {  
> > "properties" : {  
> > "value" : {"type" : "string"},  
> > "my\_boost" : {"type" : "string"}  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > The problem (as I can see 🙂 ) from your solution is that it does not  
> > use the dynamic boost (my\_boost) I store when indexing the document.
> > 
> > Am I missing something?
> > 
> > Noam.

--  
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:** ![markusos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markusos/32/2479_2.png) [@markusos](https://discuss.elastic.co/u/markusos)\
**Post date:** [February 20, 2013, 4:18pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/10 "2013-02-20T16:18:28Z")

</div>

Hi Jade!

Your example ([Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. · GitHub](https://gist.github.com/plusjade/4988626)) is close to what  
I'm trying to do, but when I run it i get an error:

$ curl -XPOST localhost:9200/p/profile -d '{  
"skills": [{ "\_value": "ruby", "\_boost": 5 }]  
}'  
{"error":"UnsupportedOperationException[You cannot set an index-time boost:  
norms are omitted for field 'skills']","status":500}

Am I missing something?

Den tisdagen den 19:e februari 2013 kl. 19:41:12 UTC+1 skrev Jade Dominguez:

> Noam, only \_boost, and boost are valid boost attribute keys. You cannot  
> use an arbitrarily named value for boosting. The mapping you've shown is  
> actually mapping an object with properties "value" and "my\_boost". You want  
> to be mapping a string type with the value of "value" and the internal  
> boost of \_boost:
> 
> {  
> "message" : {  
> "\_value": "boosted value",  
> "\_boost": 2.0  
> }  
> }
> 
> Reference:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)(under type String)
> 
> I have made a control-test example to highlight boosting by individual  
> keyword value: [Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. · GitHub](https://gist.github.com/plusjade/4988626)
> 
> Please verify you can run this and get back the expected results. Any  
> further questions should build off this control test so that we are in  
> complete alignment.
> 
> On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:
> 
> > Hi Jade,
> > 
> > First of all thanks for the reply.
> > 
> > This is how the mapping should look like:
> > 
> > {  
> > "image" : {  
> > "properties" : {  
> > "lists" : {  
> > "properties" : {  
> > "value" : {"type" : "string"},  
> > "my\_boost" : {"type" : "string"}  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > The problem (as I can see 🙂 ) from your solution is that it does not  
> > use the dynamic boost (my\_boost) I store when indexing the document.
> > 
> > Am I missing something?
> > 
> > Noam.

--  
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 20, 2013, 5:33pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/11 "2013-02-20T17:33:47Z")

</div>

did you change the field mappings? index time boosts are stored in the  
norms so you cannot set omit\_norms: false  
On Feb 20, 2013 8:18 AM, "markusos" [markus.ostberg@gmail.com](mailto:markus.ostberg@gmail.com) wrote:

> Hi Jade!
> 
> Your example ([https://gist.github](https://gist.github).\*\*com/plusjade/4988626[https://gist.github.com/plusjade/4988626](https://gist.github.com/plusjade/4988626)) is  
> close to what I'm trying to do, but when I run it i get an error:
> 
> $ curl -XPOST localhost:9200/p/profile -d '{  
> "skills": [{ "\_value": "ruby", "\_boost": 5 }]  
> }'  
> {"error":"UnsupportedOperationException[You cannot set an index-time  
> boost: norms are omitted for field 'skills']","status":500}
> 
> Am I missing something?
> 
> Den tisdagen den 19:e februari 2013 kl. 19:41:12 UTC+1 skrev Jade  
> Dominguez:
> 
> > Noam, only \_boost, and boost are valid boost attribute keys. You cannot  
> > use an arbitrarily named value for boosting. The mapping you've shown is  
> > actually mapping an object with properties "value" and "my\_boost". You want  
> > to be mapping a string type with the value of "value" and the internal  
> > boost of \_boost:
> > 
> > {  
> > "message" : {  
> > "\_value": "boosted value",  
> > "\_boost": 2.0  
> > }  
> > }
> > 
> > Reference: [http://www](http://www).**[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/)**  
> > reference/mapping/core-types.\*\*html[http://www.elasticsearch.org/guide/reference/mapping/core-types.html](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)(under type String)
> > 
> > I have made a control-test example to highlight boosting by individual  
> > keyword value: [https://gist.github](https://gist.github).\*\*com/plusjade/4988626[https://gist.github.com/plusjade/4988626](https://gist.github.com/plusjade/4988626)
> > 
> > Please verify you can run this and get back the expected results. Any  
> > further questions should build off this control test so that we are in  
> > complete alignment.
> > 
> > On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:
> > 
> > > Hi Jade,
> > > 
> > > First of all thanks for the reply.
> > > 
> > > This is how the mapping should look like:
> > > 
> > > {  
> > > "image" : {  
> > > "properties" : {  
> > > "lists" : {  
> > > "properties" : {  
> > > "value" : {"type" : "string"},  
> > > "my\_boost" : {"type" : "string"}  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > The problem (as I can see 🙂 ) from your solution is that it does not  
> > > use the dynamic boost (my\_boost) I store when indexing the document.
> > > 
> > > Am I missing something?
> > > 
> > > Noam.
> > > 
> > > --  
> > > 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:** ![markusos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markusos/32/2479_2.png) [@markusos](https://discuss.elastic.co/u/markusos)\
**Post date:** [February 20, 2013, 7:45pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/12 "2013-02-20T19:45:50Z")

</div>

I just copy the script and paste it in the terminal, have not changed  
anything in it. I get the error on all curl -XPOST localhost:9200/p/profile  
-d '{

"skills": [{ "\_value": "ruby", "\_boost": 5 }]

}' where \_boost != 1. I'm using the latest stable release (0.20.5 -  
2013-02-14).

Den onsdagen den 20:e februari 2013 kl. 18:33:47 UTC+1 skrev Jade Dominguez:

> did you change the field mappings? index time boosts are stored in the  
> norms so you cannot set omit\_norms: false  
> On Feb 20, 2013 8:18 AM, "markusos" \<[markus....@gmail.com](mailto:markus....@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > Hi Jade!
> > 
> > Your example ([https://gist.github](https://gist.github).\*\*com/plusjade/4988626[https://gist.github.com/plusjade/4988626](https://gist.github.com/plusjade/4988626)) is  
> > close to what I'm trying to do, but when I run it i get an error:
> > 
> > $ curl -XPOST localhost:9200/p/profile -d '{  
> > "skills": [{ "\_value": "ruby", "\_boost": 5 }]  
> > }'  
> > {"error":"UnsupportedOperationException[You cannot set an index-time  
> > boost: norms are omitted for field 'skills']","status":500}
> > 
> > Am I missing something?
> > 
> > Den tisdagen den 19:e februari 2013 kl. 19:41:12 UTC+1 skrev Jade  
> > Dominguez:
> > 
> > > Noam, only \_boost, and boost are valid boost attribute keys. You cannot  
> > > use an arbitrarily named value for boosting. The mapping you've shown is  
> > > actually mapping an object with properties "value" and "my\_boost". You want  
> > > to be mapping a string type with the value of "value" and the internal  
> > > boost of \_boost:
> > > 
> > > {  
> > > "message" : {  
> > > "\_value": "boosted value",  
> > > "\_boost": 2.0  
> > > }  
> > > }
> > > 
> > > Reference: [http://www](http://www).**[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/)**  
> > > reference/mapping/core-types.\*\*html[http://www.elasticsearch.org/guide/reference/mapping/core-types.html](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)(under type String)
> > > 
> > > I have made a control-test example to highlight boosting by individual  
> > > keyword value: [https://gist.github](https://gist.github).\*\*com/plusjade/4988626[https://gist.github.com/plusjade/4988626](https://gist.github.com/plusjade/4988626)
> > > 
> > > Please verify you can run this and get back the expected results. Any  
> > > further questions should build off this control test so that we are in  
> > > complete alignment.
> > > 
> > > On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:
> > > 
> > > > Hi Jade,
> > > > 
> > > > First of all thanks for the reply.
> > > > 
> > > > This is how the mapping should look like:
> > > > 
> > > > {  
> > > > "image" : {
> > > > 
> > > > ```
> > > > "properties" : {
> > > > "lists" : {
> > > > 
> > > > "properties" : {
> > > > 
> > > > "value" : {"type" : "string"}, 
> > > > 
> > > > "my_boost" : {"type" : "string"}
> > > > 
> > > > }
> > > > }
> > > > 
> > > > }
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > }
> > > > 
> > > > The problem (as I can see 🙂 ) from your solution is that it does not  
> > > > use the dynamic boost (my\_boost) I store when indexing the document.
> > > > 
> > > > Am I missing something?
> > > > 
> > > > Noam.
> > > > 
> > > > --  
> > > > 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).

--  
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:** ![markusos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markusos/32/2479_2.png) [@markusos](https://discuss.elastic.co/u/markusos)\
**Post date:** [February 21, 2013, 2:48pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/13 "2013-02-21T14:48:23Z")

</div>

Tested now in an older version of Elasticsearch (0.19.0 - 2012-03-01) and  
the example works there. Is there some reason why this doesn't work in the  
newer releases?

Den onsdagen den 20:e februari 2013 kl. 20:45:50 UTC+1 skrev markusos:

> I just copy the script and paste it in the terminal, have not changed  
> anything in it. I get the error on all curl -XPOST  
> localhost:9200/p/profile -d '{
> 
> "skills": [{ "\_value": "ruby", "\_boost": 5 }]
> 
> }' where \_boost != 1. I'm using the latest stable release (0.20.5 -  
> 2013-02-14).
> 
> Den onsdagen den 20:e februari 2013 kl. 18:33:47 UTC+1 skrev Jade  
> Dominguez:
> 
> > did you change the field mappings? index time boosts are stored in the  
> > norms so you cannot set omit\_norms: false  
> > On Feb 20, 2013 8:18 AM, "markusos" [markus....@gmail.com](mailto:markus....@gmail.com) wrote:
> > 
> > > Hi Jade!
> > > 
> > > Your example ([https://gist.github](https://gist.github).\*\*com/plusjade/4988626[https://gist.github.com/plusjade/4988626](https://gist.github.com/plusjade/4988626)) is  
> > > close to what I'm trying to do, but when I run it i get an error:
> > > 
> > > $ curl -XPOST localhost:9200/p/profile -d '{  
> > > "skills": [{ "\_value": "ruby", "\_boost": 5 }]  
> > > }'  
> > > {"error":"UnsupportedOperationException[You cannot set an index-time  
> > > boost: norms are omitted for field 'skills']","status":500}
> > > 
> > > Am I missing something?
> > > 
> > > Den tisdagen den 19:e februari 2013 kl. 19:41:12 UTC+1 skrev Jade  
> > > Dominguez:
> > > 
> > > > Noam, only \_boost, and boost are valid boost attribute keys. You cannot  
> > > > use an arbitrarily named value for boosting. The mapping you've shown is  
> > > > actually mapping an object with properties "value" and "my\_boost". You want  
> > > > to be mapping a string type with the value of "value" and the internal  
> > > > boost of \_boost:
> > > > 
> > > > {  
> > > > "message" : {  
> > > > "\_value": "boosted value",  
> > > > "\_boost": 2.0  
> > > > }  
> > > > }
> > > > 
> > > > Reference: [http://www](http://www).**[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/)**  
> > > > reference/mapping/core-types.\*\*html[http://www.elasticsearch.org/guide/reference/mapping/core-types.html](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)(under type String)
> > > > 
> > > > I have made a control-test example to highlight boosting by individual  
> > > > keyword value: [https://gist.github](https://gist.github).\*\*com/plusjade/4988626[https://gist.github.com/plusjade/4988626](https://gist.github.com/plusjade/4988626)
> > > > 
> > > > Please verify you can run this and get back the expected results. Any  
> > > > further questions should build off this control test so that we are in  
> > > > complete alignment.
> > > > 
> > > > On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:
> > > > 
> > > > > Hi Jade,
> > > > > 
> > > > > First of all thanks for the reply.
> > > > > 
> > > > > This is how the mapping should look like:
> > > > > 
> > > > > {  
> > > > > "image" : {
> > > > > 
> > > > > ```
> > > > > "properties" : {
> > > > > "lists" : {
> > > > > 
> > > > > "properties" : {
> > > > > 
> > > > > "value" : {"type" : "string"}, 
> > > > > 
> > > > > "my_boost" : {"type" : "string"}
> > > > > 
> > > > > }
> > > > > }
> > > > > 
> > > > > }
> > > > > }
> > > > > 
> > > > > ```
> > > > > 
> > > > > }
> > > > > 
> > > > > The problem (as I can see 🙂 ) from your solution is that it does not  
> > > > > use the dynamic boost (my\_boost) I store when indexing the document.
> > > > > 
> > > > > Am I missing something?
> > > > > 
> > > > > Noam.
> > > > > 
> > > > > --  
> > > > > 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).  
> > > > > 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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 21, 2013, 2:50pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/14 "2013-02-21T14:50:57Z")

</div>

Hi Noam

> I know something like this was already answered but it's not what I  
> need 🙂
> 
> I have two documents that look like this:
> 
> {  
> "image" : {  
> "lists" : [  
> {  
> "value" : "dior",  
> "my\_boost" : "10"  
> },  
> {  
> "value" : "red",  
> "my\_boost" : "2"  
> }  
> ]  
> }  
> }
> 
> {  
> "image" : {  
> "lists" : [  
> {  
> "value" : "dior",  
> "my\_boost" : "2"  
> },  
> {  
> "value" : "red",  
> "my\_boost" : "10"  
> }  
> ]  
> }
> 
> If I search for "red" I will get these two documents.
> 
> BUT 🙂
> 
> I would like the query to use the my\_boost field to push the score  
> higher for the relevant search
> 
> This means that I want the second document to be first (because it has  
> a my\_boost=10).
> 
> I was thinking that custom\_score & script might help me - but I don't  
> know how to accomplish it.

A custom\_score script is the way to go, but the other complication is  
that you are using an array of objects. In order to consider the  
properties in each object independently, you need to change lists to be  
of type "nested".

I have written a complete example showing how to achieve what you want  
on stackoverflow:

> <https://stackoverflow.com/questions/14504180/elasticsearch-sorting-by-nested-documents-values/14519947#14519947>

clint

--  
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:** ![Noam\_Guy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/noam_guy/32/2478_2.png) [@Noam\_Guy](https://discuss.elastic.co/u/Noam_Guy)\
**Post date:** [February 21, 2013, 3:01pm UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/15 "2013-02-21T15:01:09Z")

</div>

Great I will take a look at it as soon as the kids go to sleep 🙂  
On Feb 21, 2013 4:51 PM, "Clinton Gormley" [clint@traveljury.com](mailto:clint@traveljury.com) wrote:

> Hi Noam
> 
> > I know something like this was already answered but it's not what I  
> > need 🙂
> > 
> > I have two documents that look like this:
> > 
> > {  
> > "image" : {  
> > "lists" : [  
> > {  
> > "value" : "dior",  
> > "my\_boost" : "10"  
> > },  
> > {  
> > "value" : "red",  
> > "my\_boost" : "2"  
> > }  
> > ]  
> > }  
> > }
> > 
> > {  
> > "image" : {  
> > "lists" : [  
> > {  
> > "value" : "dior",  
> > "my\_boost" : "2"  
> > },  
> > {  
> > "value" : "red",  
> > "my\_boost" : "10"  
> > }  
> > ]  
> > }
> > 
> > If I search for "red" I will get these two documents.
> > 
> > BUT 🙂
> > 
> > I would like the query to use the my\_boost field to push the score  
> > higher for the relevant search
> > 
> > This means that I want the second document to be first (because it has  
> > a my\_boost=10).
> > 
> > I was thinking that custom\_score & script might help me - but I don't  
> > know how to accomplish it.
> 
> A custom\_score script is the way to go, but the other complication is  
> that you are using an array of objects. In order to consider the  
> properties in each object independently, you need to change lists to be  
> of type "nested".
> 
> I have written a complete example showing how to achieve what you want  
> on stackoverflow:
> 
> [java - ElasticSearch : Sorting by nested documents' values - Stack Overflow](http://stackoverflow.com/questions/14504180/elasticsearch-sorting-parents-through-child-values/14519947#14519947)
> 
> clint
> 
> --  
> 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:** ![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:50am UTC](https://discuss.elastic.co/t/boosting-a-document-value/10770/16 "2017-07-06T02:50:18Z")

</div>


