# Syntax for combining boosted query components

**URL:** <https://discuss.elastic.co/t/syntax-for-combining-boosted-query-components/4377>\
**Category:** Elasticsearch\
**Created:** [May 10, 2011, 9:55pm UTC](https://discuss.elastic.co/t/syntax-for-combining-boosted-query-components/4377 "2011-05-10T21:55:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![conor](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@conor](https://discuss.elastic.co/u/conor)\
**Post date:** [May 10, 2011, 9:55pm UTC](https://discuss.elastic.co/t/syntax-for-combining-boosted-query-components/4377/1 "2011-05-10T21:55:59Z")

</div>

Hello all.

I am testing different query options and want to try combining  
different query elements together with a boosting factor. So for  
example, suppose I want to use a more\_like\_this query for some  
like\_text against a field AND I would like to use a trem query against  
a different field. And I would like to combine these elements such  
that the term query is boosted by a factor of 2.

Assume the fields are field\_a, field\_b and field\_c (all strings).  
Assume the first query element is:- "more\_like\_this": {"like\_text":  
"text like this", fields: ["field\_a", "field\_b"]}  
Assume the second query element is:- "term": {"field\_c": {"value":  
"foo", "boost": 2.0}}

And the question is, what is the right syntax to put these together in  
a query?

Thanks,

Conor

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 11, 2011, 8:10pm UTC](https://discuss.elastic.co/t/syntax-for-combining-boosted-query-components/4377/2 "2011-05-11T20:10:29Z")

</div>

You can put them in a bool query should/must clauses.  
On Wednesday, May 11, 2011 at 12:55 AM, Conor wrote:

> Hello all.
> 
> I am testing different query options and want to try combining  
> different query elements together with a boosting factor. So for  
> example, suppose I want to use a more\_like\_this query for some  
> like\_text against a field AND I would like to use a trem query against  
> a different field. And I would like to combine these elements such  
> that the term query is boosted by a factor of 2.
> 
> Assume the fields are field\_a, field\_b and field\_c (all strings).  
> Assume the first query element is:- "more\_like\_this": {"like\_text":  
> "text like this", fields: ["field\_a", "field\_b"]}  
> Assume the second query element is:- "term": {"field\_c": {"value":  
> "foo", "boost": 2.0}}
> 
> And the question is, what is the right syntax to put these together in  
> a query?
> 
> Thanks,
> 
> Conor

---

<div class="post-metadata">

**Author:** ![conor](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@conor](https://discuss.elastic.co/u/conor)\
**Post date:** [May 11, 2011, 10:08pm UTC](https://discuss.elastic.co/t/syntax-for-combining-boosted-query-components/4377/3 "2011-05-11T22:08:27Z")

</div>

Thanks. It was not intuitive to me that a boolean combination of fuzzy component queries (i.e. not an underlying boolean value but a score) were the semantics, but it does the job nicely.

The test query I used is listed below.

Cheers.

# C

{ "query":  
{"bool" :  
{ "should": [  
{"mlt":  
{ "like\_text": "bar bar foo bing", "min\_doc\_freq": 1 }  
},  
{"term" :  
{ "field\_c": { "value": "baz", "boost": 4.0}}  
}  
]}  
}  
}

---

<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, 4:06am UTC](https://discuss.elastic.co/t/syntax-for-combining-boosted-query-components/4377/4 "2017-07-06T04:06:24Z")

</div>

Closed on July 6, 2017, 4:06am UTC


