# Scoring when query match a single field

**URL:** https://discuss.elastic.co/t/scoring-when-query-match-a-single-field/11951
**Category:** Elasticsearch
**Created:** [May 14, 2013, 9:37am UTC](https://discuss.elastic.co/t/scoring-when-query-match-a-single-field/11951 "2013-05-14T09:37:51Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sebastianpx](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Sebastianpx](https://discuss.elastic.co/u/Sebastianpx)
#### Post date: [May 14, 2013, 9:37am UTC](https://discuss.elastic.co/t/scoring-when-query-match-a-single-field/11951/1 "2013-05-14T09:37:51Z")

</div>

Hi !

I am currently indexing documents that represent a category page.  
This documents have different fields like "category" and "brand".

Let's imagine a document A having category "Fashion" and no brand defined,  
and a document B having category "Fashion" and brand "Adidas".  
When I am querying for "Fashion" in the fields category and brand, I would  
like the document A having a higher score then the document B.

Currently, the reverse is happening. How could I avoid it ?

When a document has only one field which is matching, I would like its  
score beeing higher then an other document having the same field matching +  
other fields defined.

I am not sure that my question is very clear so I have added some  
information about my mapping, the query I am doing and the results I  
am currently getting here :

> <https://gist.github.com/anonymous/5574793>

Thank you in advance !

Sebastian

--  
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: [May 14, 2013, 9:43am UTC](https://discuss.elastic.co/t/scoring-when-query-match-a-single-field/11951/2 "2013-05-14T09:43:55Z")

</div>

What happens if you set boost to 0.5 for brand field?

Just a side note: you can set boosting at query time instead of index time.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 14 mai 2013 à 11:37, Sebastianpx [sebastian.piedoux@gmail.com](mailto:sebastian.piedoux@gmail.com) a écrit :

> Hi !
> 
> I am currently indexing documents that represent a category page.  
> This documents have different fields like "category" and "brand".
> 
> Let's imagine a document A having category "Fashion" and no brand defined, and a document B having category "Fashion" and brand "Adidas".  
> When I am querying for "Fashion" in the fields category and brand, I would like the document A having a higher score then the document B.
> 
> Currently, the reverse is happening. How could I avoid it ?
> 
> When a document has only one field which is matching, I would like its score beeing higher then an other document having the same field matching + other fields defined.
> 
> I am not sure that my question is very clear so I have added some information about my mapping, the query I am doing and the results I am currently getting here :  
> [gist:5574793 · GitHub](https://gist.github.com/anonymous/5574793)
> 
> Thank you in advance !
> 
> Sebastian
> 
> --  
> 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: ![Sebastianpx](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Sebastianpx](https://discuss.elastic.co/u/Sebastianpx)
#### Post date: [May 14, 2013, 9:53am UTC](https://discuss.elastic.co/t/scoring-when-query-match-a-single-field/11951/3 "2013-05-14T09:53:04Z")

</div>

Thank you for your help David.

I just tried it out but actually it is even worst. In the example I posted  
on gist, my document having only "category":"Moda" without any other fields  
is now in position 4.

On Tuesday, 14 May 2013 11:45:17 UTC+2, David Pilato wrote:

> What happens if you set boost to 0.5 for brand field?
> 
> Just a side note: you can set boosting at query time instead of index time.
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 14 mai 2013 à 11:37, Sebastianpx \<[sebastia...@gmail.com](mailto:sebastia...@gmail.com) \<javascript:\>\>  
> a écrit :
> 
> Hi !
> 
> I am currently indexing documents that represent a category page.  
> This documents have different fields like "category" and "brand".
> 
> Let's imagine a document A having category "Fashion" and no brand defined,  
> and a document B having category "Fashion" and brand "Adidas".  
> When I am querying for "Fashion" in the fields category and brand, I would  
> like the document A having a higher score then the document B.
> 
> Currently, the reverse is happening. How could I avoid it ?
> 
> When a document has only one field which is matching, I would like its  
> score beeing higher then an other document having the same field matching +  
> other fields defined.
> 
> I am not sure that my question is very clear so I have added some  
> information about my mapping, the query I am doing and the results I  
> am currently getting here :  
> [gist:5574793 · GitHub](https://gist.github.com/anonymous/5574793)
> 
> Thank you in advance !
> 
> Sebastian
> 
> --  
> 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: ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)
#### Post date: [May 15, 2013, 4:23am UTC](https://discuss.elastic.co/t/scoring-when-query-match-a-single-field/11951/4 "2013-05-15T04:23:50Z")

</div>

can you maybe use a

> **[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.

with a

> **[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.

and give docs a boost that don't have a value in a certain field?

simon

On Tuesday, May 14, 2013 11:37:51 AM UTC+2, Sebastianpx wrote:

> Hi !
> 
> I am currently indexing documents that represent a category page.  
> This documents have different fields like "category" and "brand".
> 
> Let's imagine a document A having category "Fashion" and no brand defined,  
> and a document B having category "Fashion" and brand "Adidas".  
> When I am querying for "Fashion" in the fields category and brand, I would  
> like the document A having a higher score then the document B.
> 
> Currently, the reverse is happening. How could I avoid it ?
> 
> When a document has only one field which is matching, I would like its  
> score beeing higher then an other document having the same field matching +  
> other fields defined.
> 
> I am not sure that my question is very clear so I have added some  
> information about my mapping, the query I am doing and the results I  
> am currently getting here :  
> [gist:5574793 · GitHub](https://gist.github.com/anonymous/5574793)
> 
> Thank you in advance !
> 
> Sebastian

--  
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: ![Sebastianpx](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Sebastianpx](https://discuss.elastic.co/u/Sebastianpx)
#### Post date: [May 16, 2013, 2:46pm UTC](https://discuss.elastic.co/t/scoring-when-query-match-a-single-field/11951/5 "2013-05-16T14:46:28Z")

</div>

Hi Simon !

Thanks for you answer. I gave it a try with boosting missing fields but  
still I am not notally satisfied with the result.  
If I have one document with category "Moda" and an other document with  
category "Moda" and brand "Vera Moda", the score of the second document is  
still higher then the first one.  
My query looks like that:

{  
"query": {  
"custom\_filters\_score": {  
"query": {  
"multi\_match": {  
"query": "Moda",  
"fields": [  
"category",  
"brand"  
]  
}  
},  
"filters": [  
{  
"filter": {  
"missing": {  
"field": "brand"  
}  
},  
"boost": "10"  
},  
{  
"filter": {  
"missing": {  
"field": "category"  
}  
},  
"boost": "10"  
}  
],  
"score\_mode": "first"  
}  
}  
}

Did I do something wrong ?

Sebastian

On Wednesday, 15 May 2013 06:23:50 UTC+2, simonw wrote:

> can you maybe use a
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query/)
> 
> with a
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/missing-filter/)
> 
> and give docs a boost that don't have a value in a certain field?
> 
> simon
> 
> On Tuesday, May 14, 2013 11:37:51 AM UTC+2, Sebastianpx wrote:
> 
> > Hi !
> > 
> > I am currently indexing documents that represent a category page.  
> > This documents have different fields like "category" and "brand".
> > 
> > Let's imagine a document A having category "Fashion" and no brand  
> > defined, and a document B having category "Fashion" and brand "Adidas".  
> > When I am querying for "Fashion" in the fields category and brand, I  
> > would like the document A having a higher score then the document B.
> > 
> > Currently, the reverse is happening. How could I avoid it ?
> > 
> > When a document has only one field which is matching, I would like its  
> > score beeing higher then an other document having the same field matching +  
> > other fields defined.
> > 
> > I am not sure that my question is very clear so I have added some  
> > information about my mapping, the query I am doing and the results I  
> > am currently getting here :  
> > [gist:5574793 · GitHub](https://gist.github.com/anonymous/5574793)
> > 
> > Thank you in advance !
> > 
> > Sebastian

--  
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:36am UTC](https://discuss.elastic.co/t/scoring-when-query-match-a-single-field/11951/6 "2017-07-06T02:36:16Z")

</div>


