# Combining Filtered Query with Query String and Exact Match

**URL:** <https://discuss.elastic.co/t/combining-filtered-query-with-query-string-and-exact-match/22379>\
**Category:** Elasticsearch\
**Created:** [February 25, 2015, 10:22am UTC](https://discuss.elastic.co/t/combining-filtered-query-with-query-string-and-exact-match/22379 "2015-02-25T10:22:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jim\_Cumming](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@Jim\_Cumming](https://discuss.elastic.co/u/Jim_Cumming)\
**Post date:** [February 25, 2015, 10:22am UTC](https://discuss.elastic.co/t/combining-filtered-query-with-query-string-and-exact-match/22379/1 "2015-02-25T10:22:17Z")

</div>

Hi All, I'm having some trouble bending the query api to my requirements on  
this one and was wondering if someone could point me in the right  
direction.

We want to search some website content using the query string query. This  
needs to be filtered by various terms. However we need to boost a result if  
there is an exact match on the tags field. The tags field is an array of  
values, so this would be an exact match on 1 of the items in the array.

I started with this query

{  
"from": 0,  
"size": 20,  
"query": {  
"filtered": {  
"query": {  
"query\_string": {  
"fields": [  
"title^2",  
"body",  
"file",  
"summary",  
"tags^10"  
],  
"query": "Research Institute",  
"use\_dis\_max": true  
}  
},  
"filter": {  
"bool": {  
"must": [  
{  
"terms": {  
"type": [  
"file",  
"page",  
"link",  
"folder",  
"calendar"  
]  
}  
}  
]  
}  
}  
}  
}  
}

But this boosts items with the tag of just 'Research' as well as 'Research  
Institute' and ends up promoting some fairly irrelevant results.

I thought of using a bool query with a filtered query element and a match  
query with a boost value, but ES wont execute that. Does anyone have any  
suggestions?

--  
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/ae72db3d-b2c2-4651-ab5f-f9930c8796ef%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ae72db3d-b2c2-4651-ab5f-f9930c8796ef%40googlegroups.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, 12:30am UTC](https://discuss.elastic.co/t/combining-filtered-query-with-query-string-and-exact-match/22379/2 "2017-07-06T00:30:15Z")

</div>

Closed on July 6, 2017, 12:30am UTC


