# Penalty or boost from a boolean property

**URL:** https://discuss.elastic.co/t/penalty-or-boost-from-a-boolean-property/18235
**Category:** Elasticsearch
**Created:** [June 20, 2014, 5:50pm UTC](https://discuss.elastic.co/t/penalty-or-boost-from-a-boolean-property/18235 "2014-06-20T17:50:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![hugo\_lassiege](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_lassiege/32/1465_2.png) [@hugo\_lassiege](https://discuss.elastic.co/u/hugo_lassiege)
#### Post date: [June 20, 2014, 5:50pm UTC](https://discuss.elastic.co/t/penalty-or-boost-from-a-boolean-property/18235/1 "2014-06-20T17:50:25Z")

</div>

Hi,

I'm looking for help 🙂 This is maybe trivial but I can't find the good  
solution.

I have some documents and those documents have two boolean properties,  
basically thumbs up and thumbs down to show that the administrator approve  
or not those documents.  
I try to boost a document if it is "thumbsup" or demote the document if it  
is thumbsdown. It's not a filter, the document could be retrieved, it's  
just more or less relevant.

I tried with two should clauses in the global request :

{  
"bool" : {  
"should" : [  
{  
"term" : { "champ1" : "valeur1" }  
},  
{  
"term" : { "champ2" : "valeur2" }  
},  
{  
"term" : { "thumbsup" : true }  
},  
{  
"term" : { "thumbsdown" : false}  
}  
]  
}  
}

But I get some irrelevant documents because they match the last conditions.  
What would be the best method for this use case ?

--  
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/ba3964f0-fbc8-4e0c-be3f-c38af8221410%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ba3964f0-fbc8-4e0c-be3f-c38af8221410%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [June 20, 2014, 5:54pm UTC](https://discuss.elastic.co/t/penalty-or-boost-from-a-boolean-property/18235/2 "2014-06-20T17:54:16Z")

</div>

Function\_score is the way to go IMHO.

Best

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

> Le 20 juin 2014 à 19:50, hugo lassiege [hlassiege@gmail.com](mailto:hlassiege@gmail.com) a écrit :
> 
> Hi,
> 
> I'm looking for help 🙂 This is maybe trivial but I can't find the good solution.
> 
> I have some documents and those documents have two boolean properties, basically thumbs up and thumbs down to show that the administrator approve or not those documents.  
> I try to boost a document if it is "thumbsup" or demote the document if it is thumbsdown. It's not a filter, the document could be retrieved, it's just more or less relevant.
> 
> I tried with two should clauses in the global request :
> 
> {  
> "bool" : {  
> "should" : [  
> {  
> "term" : { "champ1" : "valeur1" }  
> },  
> {  
> "term" : { "champ2" : "valeur2" }  
> },  
> {  
> "term" : { "thumbsup" : true }  
> },  
> {  
> "term" : { "thumbsdown" : false}  
> }  
> ]  
> }  
> }
> 
> ## But I get some irrelevant documents because they match the last conditions. What would be the best method for this use case ?
> 
> 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/ba3964f0-fbc8-4e0c-be3f-c38af8221410%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ba3964f0-fbc8-4e0c-be3f-c38af8221410%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/088863F1-E2EA-45A6-9368-D9AA69E717FE%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/088863F1-E2EA-45A6-9368-D9AA69E717FE%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![hugo\_lassiege](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_lassiege/32/1465_2.png) [@hugo\_lassiege](https://discuss.elastic.co/u/hugo_lassiege)
#### Post date: [June 24, 2014, 11:16am UTC](https://discuss.elastic.co/t/penalty-or-boost-from-a-boolean-property/18235/3 "2014-06-24T11:16:40Z")

</div>

Thanks for your help. It works 🙂

2014-06-20 19:54 GMT+02:00 David Pilato [david@pilato.fr](mailto:david@pilato.fr):

> Function\_score is the way to go IMHO.
> 
> Best
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 20 juin 2014 à 19:50, hugo lassiege [hlassiege@gmail.com](mailto:hlassiege@gmail.com) a écrit :
> 
> Hi,
> 
> I'm looking for help 🙂 This is maybe trivial but I can't find the good  
> solution.
> 
> I have some documents and those documents have two boolean properties,  
> basically thumbs up and thumbs down to show that the administrator approve  
> or not those documents.  
> I try to boost a document if it is "thumbsup" or demote the document if it  
> is thumbsdown. It's not a filter, the document could be retrieved, it's  
> just more or less relevant.
> 
> I tried with two should clauses in the global request :
> 
> {  
> "bool" : {  
> "should" : [  
> {  
> "term" : { "champ1" : "valeur1" }  
> },  
> {  
> "term" : { "champ2" : "valeur2" }  
> },  
> {  
> "term" : { "thumbsup" : true }  
> },  
> {  
> "term" : { "thumbsdown" : false}  
> }  
> ]  
> }  
> }
> 
> But I get some irrelevant documents because they match the last  
> conditions.  
> What would be the best method for this use case ?
> 
> --  
> 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/ba3964f0-fbc8-4e0c-be3f-c38af8221410%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ba3964f0-fbc8-4e0c-be3f-c38af8221410%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/ba3964f0-fbc8-4e0c-be3f-c38af8221410%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/ba3964f0-fbc8-4e0c-be3f-c38af8221410%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/26Y62Eisrm4/unsubscribe](https://groups.google.com/d/topic/elasticsearch/26Y62Eisrm4/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/088863F1-E2EA-45A6-9368-D9AA69E717FE%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/088863F1-E2EA-45A6-9368-D9AA69E717FE%40pilato.fr)  
> [https://groups.google.com/d/msgid/elasticsearch/088863F1-E2EA-45A6-9368-D9AA69E717FE%40pilato.fr?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/088863F1-E2EA-45A6-9368-D9AA69E717FE%40pilato.fr?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAKXL5Nh7wPrYMpkE7NmopbOULT34w\_etBgD076YTUBnpoYxbhQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKXL5Nh7wPrYMpkE7NmopbOULT34w_etBgD076YTUBnpoYxbhQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:20am UTC](https://discuss.elastic.co/t/penalty-or-boost-from-a-boolean-property/18235/4 "2017-07-06T01:20:14Z")

</div>


