# Its possible to give a different boost to queries in an OR condition filter?

**URL:** <https://discuss.elastic.co/t/its-possible-to-give-a-different-boost-to-queries-in-an-or-condition-filter/13153>\
**Category:** Elasticsearch\
**Created:** [August 9, 2013, 4:16pm UTC](https://discuss.elastic.co/t/its-possible-to-give-a-different-boost-to-queries-in-an-or-condition-filter/13153 "2013-08-09T16:16:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![poncho1984](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@poncho1984](https://discuss.elastic.co/u/poncho1984)\
**Post date:** [August 9, 2013, 4:16pm UTC](https://discuss.elastic.co/t/its-possible-to-give-a-different-boost-to-queries-in-an-or-condition-filter/13153/1 "2013-08-09T16:16:14Z")

</div>

I have the next query with gets my all what could possible match with what  
a user types on a text, what i need to do is to add a boost to a query  
inside an OR condition, i need to rank higher the documents that are of a  
certain type.  
Wich will be the best approach to do this????

{  
"filter": {  
"term": {  
"status": 1  
}  
},  
"from": 0,  
"size": 8,  
"query": {  
"filtered": {  
"query": {  
"query\_string": {  
"query": "grid~"  
}  
},  
"filter": {  
"and": [  
{  
"or": [  
{  
"geo\_distance": {  
"distance": "75mi",  
"field\_point:latlon":  
"47.6062095,-122.3320708"  
}  
},  
{  
"missing": {  
"field": "field\_point:latlon",  
"existence": true,  
"null\_value": true  
}  
}  
]  
},  
{  
"or": [  
{  
"query": {  
"query\_string": {  
"query": "(field\_state:ALL OR  
field\_state:'WA') AND type:incentive"

- 

```
  "I need to give a high rank to this query over the other on this OR 

```

"\*  
}  
}  
},  
{  
"query": {  
"query\_string": {  
"query": "\* AND NOT  
(type:adcampaign OR type:incentive OR type:page\_simple OR type:page OR  
type:glossary\_item OR type:product OR type:lighting\_option)"  
}  
}  
}  
]  
},  
{  
"query": {  
"query\_string": {  
"query": "status:1"  
}  
}  
}  
]  
}  
}  
},  
"facets": {  
"type": {  
"terms": {  
"field": "type",  
"size": 100  
}  
},  
"field\_energy\_advisor": {  
"terms": {  
"field": "field\_energy\_advisor",  
"size": 100  
}  
}  
}  
}

--  
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:** [August 10, 2013, 10:42am UTC](https://discuss.elastic.co/t/its-possible-to-give-a-different-boost-to-queries-in-an-or-condition-filter/13153/2 "2013-08-10T10:42:23Z")

</div>

You need to change your filter to be a query in order to influence score  
with filtered. Once it's a query you can simply boost it.  
Filters only "filter" while queries also score.

simon

On Friday, August 9, 2013 6:16:14 PM UTC+2, Alfonso Noguez wrote:

> I have the next query with gets my all what could possible match with what  
> a user types on a text, what i need to do is to add a boost to a query  
> inside an OR condition, i need to rank higher the documents that are of a  
> certain type.  
> Wich will be the best approach to do this????
> 
> {  
> "filter": {  
> "term": {  
> "status": 1  
> }  
> },  
> "from": 0,  
> "size": 8,  
> "query": {  
> "filtered": {  
> "query": {  
> "query\_string": {  
> "query": "grid~"  
> }  
> },  
> "filter": {  
> "and": [  
> {  
> "or": [  
> {  
> "geo\_distance": {  
> "distance": "75mi",  
> "field\_point:latlon":  
> "47.6062095,-122.3320708"  
> }  
> },  
> {  
> "missing": {  
> "field": "field\_point:latlon",  
> "existence": true,  
> "null\_value": true  
> }  
> }  
> ]  
> },  
> {  
> "or": [  
> {  
> "query": {  
> "query\_string": {  
> "query": "(field\_state:ALL OR  
> field\_state:'WA') AND type:incentive"
> 
> - 
> 
> ```
> "I need to give a high rank to this query over the other on this 
> 
> ```
> 
> OR "\*  
> }  
> }  
> },  
> {  
> "query": {  
> "query\_string": {  
> "query": "\* AND NOT  
> (type:adcampaign OR type:incentive OR type:page\_simple OR type:page OR  
> type:glossary\_item OR type:product OR type:lighting\_option)"  
> }  
> }  
> }  
> ]  
> },  
> {  
> "query": {  
> "query\_string": {  
> "query": "status:1"  
> }  
> }  
> }  
> ]  
> }  
> }  
> },  
> "facets": {  
> "type": {  
> "terms": {  
> "field": "type",  
> "size": 100  
> }  
> },  
> "field\_energy\_advisor": {  
> "terms": {  
> "field": "field\_energy\_advisor",  
> "size": 100  
> }  
> }  
> }  
> }

--  
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:21am UTC](https://discuss.elastic.co/t/its-possible-to-give-a-different-boost-to-queries-in-an-or-condition-filter/13153/3 "2017-07-06T02:21:45Z")

</div>


