# How can we combine Query DSL and Query time boosting to control relevance

**URL:** <https://discuss.elastic.co/t/how-can-we-combine-query-dsl-and-query-time-boosting-to-control-relevance/73318>\
**Category:** Elasticsearch\
**Created:** [January 31, 2017, 7:16am UTC](https://discuss.elastic.co/t/how-can-we-combine-query-dsl-and-query-time-boosting-to-control-relevance/73318 "2017-01-31T07:16:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atul\_Bagga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_bagga/32/15047_2.png) [@Atul\_Bagga](https://discuss.elastic.co/u/Atul_Bagga)\
**Post date:** [January 31, 2017, 7:16am UTC](https://discuss.elastic.co/t/how-can-we-combine-query-dsl-and-query-time-boosting-to-control-relevance/73318/1 "2017-01-31T07:16:42Z")

</div>

I want to boost the relevance of one type of documents over another. The way to differentiate between the documents is on the basis of a field value say "type" which can be "a" or "b".

For type "a" I want to use different query time boost values than for type "b".

Is there a way to achieve this?

One way could be to use my custom script for scoring but I am avoiding that path if this can be directly achieved by elastic search for performance and maintenance overheads.

Thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 31, 2017, 8:51am UTC](https://discuss.elastic.co/t/how-can-we-combine-query-dsl-and-query-time-boosting-to-control-relevance/73318/2 "2017-01-31T08:51:43Z")

</div>

Hey,

you can configure boosting based on the `_type` field. So you would need to use a `filter` query on the `_type` field as part of a should clause.

Hope that makes sense.

--Alex

---

<div class="post-metadata">

**Author:** ![Atul\_Bagga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_bagga/32/15047_2.png) [@Atul\_Bagga](https://discuss.elastic.co/u/Atul_Bagga)\
**Post date:** [January 31, 2017, 10:50am UTC](https://discuss.elastic.co/t/how-can-we-combine-query-dsl-and-query-time-boosting-to-control-relevance/73318/3 "2017-01-31T10:50:06Z")

</div>

I guess my use of the word type was misleading. Actually they are both same \_type as far as Elastic Search is concerned. The type for me is my own field in the document lets say category a and category b.

Now I want to configure boosting on same field with different value for different category of documents.

Say I want to give boost of 2 to name in case of document category = a and boost 1 for document in category b.

I saw this but I am not sure if I can use something similar.. I need to boost multiple fields differently on basis of some field value in the document.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 31, 2017, 11:31am UTC](https://discuss.elastic.co/t/how-can-we-combine-query-dsl-and-query-time-boosting-to-control-relevance/73318/4 "2017-01-31T11:31:59Z")

</div>

Check out the examples in [the definitive guide](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/_boosting_query_clauses.html) - there is one examples with two should clauses based on the content.. instead of a `match` query you may just need a `term` one

---

<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:** [February 28, 2017, 11:32am UTC](https://discuss.elastic.co/t/how-can-we-combine-query-dsl-and-query-time-boosting-to-control-relevance/73318/5 "2017-02-28T11:32:02Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
