# Query terms boosting

**URL:** <https://discuss.elastic.co/t/query-terms-boosting/5277>\
**Category:** Elasticsearch\
**Created:** [August 30, 2011, 10:04am UTC](https://discuss.elastic.co/t/query-terms-boosting/5277 "2011-08-30T10:04:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![konstantin](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@konstantin](https://discuss.elastic.co/u/konstantin)\
**Post date:** [August 30, 2011, 10:04am UTC](https://discuss.elastic.co/t/query-terms-boosting/5277/1 "2011-08-30T10:04:42Z")

</div>

Hi,

I want to increase a significancy for some terms in the query. E.g.  
increase term 'iphone' in phrase 'I like iphone'.  
The recipe i found so far is 'query\_string':

{  
"query": {  
"query\_string": {  
"query": "I like iphone^5.0"  
}  
}  
}

The first question is do I lose the 'analysis' for this query. I mean  
if I set up stemmer will it work? Or for that kind of query the string  
will be processed 'as is'.  
And the second - Are there any better ways to do it? Mb I should use  
boolean query with term boosting instead?

Thanks!

ps posted to nabble previously, but seems it ignored the post.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [August 30, 2011, 10:44am UTC](https://discuss.elastic.co/t/query-terms-boosting/5277/2 "2011-08-30T10:44:14Z")

</div>

Hi Konstantin

> I want to increase a significancy for some terms in the query. E.g.  
> increase term 'iphone' in phrase 'I like iphone'.  
> The recipe i found so far is 'query\_string':
> 
> {  
> "query": {  
> "query\_string": {  
> "query": "I like iphone^5.0"  
> }  
> }  
> }
> 
> The first question is do I lose the 'analysis' for this query. I mean  
> if I set up stemmer will it work? Or for that kind of query the string  
> will be processed 'as is'.

The analysis will still work.

> And the second - Are there any better ways to do it? Mb I should use  
> boolean query with term boosting instead?

I would say yes, there are better ways. Trying to express your whole  
query in the lucene query string syntax becomes quite messy.

The query string syntax gets converted into multiple queries combined  
with bool and dismax queries anyway, so you can use the query DSL to  
combine queries with different boosts yourself

clint

---

<div class="post-metadata">

**Author:** ![konstantin](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@konstantin](https://discuss.elastic.co/u/konstantin)\
**Post date:** [August 30, 2011, 12:00pm UTC](https://discuss.elastic.co/t/query-terms-boosting/5277/3 "2011-08-30T12:00:17Z")

</div>

Thanks a lot Clinton,

I'm starting to understand how it works.  
Should the query below be a rough equivalent of the previous one?

curl -XGET 'localhost:9200/test/item/\_search?pretty=true' -d '  
{  
"query": {  
"bool": {  
"should": [  
{  
"text": { "\_all": "I like iphone" }  
},  
{  
"term": {  
"\_all": {  
"value": "iphone",  
"boost": 5.0  
}  
}  
}  
]  
}  
}  
}'

btw are there any tricks to find out what lucene query I get after the  
ES processing?

Thanks!

On Aug 30, 2:44 pm, Clinton Gormley [cl...@traveljury.com](mailto:cl...@traveljury.com) wrote:

> Hi Konstantin
> 
> > I want to increase a significancy for some terms in the query. E.g.  
> > increase term 'iphone' in phrase 'I like iphone'.  
> > The recipe i found so far is 'query\_string':
> 
> > {  
> > "query": {  
> > "query\_string": {  
> > "query": "I like iphone^5.0"  
> > }  
> > }  
> > }
> 
> > The first question is do I lose the 'analysis' for this query. I mean  
> > if I set up stemmer will it work? Or for that kind of query the string  
> > will be processed 'as is'.
> 
> The analysis will still work.
> 
> > And the second - Are there any better ways to do it? Mb I should use  
> > boolean query with term boosting instead?
> 
> I would say yes, there are better ways. Trying to express your whole  
> query in the lucene query string syntax becomes quite messy.
> 
> The query string syntax gets converted into multiple queries combined  
> with bool and dismax queries anyway, so you can use the query DSL to  
> combine queries with different boosts yourself
> 
> clint

---

<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:** [August 30, 2011, 2:25pm UTC](https://discuss.elastic.co/t/query-terms-boosting/5277/4 "2011-08-30T14:25:08Z")

</div>

Most of the queries map one to one to the Lucene Query. text is a bit  
different since it analyzes the text and then constructs a boolean / prefix  
/ phrase prefix query out of it.

On Tue, Aug 30, 2011 at 3:00 PM, konstantin  
[konstantin.selivanov@gmail.com](mailto:konstantin.selivanov@gmail.com)wrote:

> Thanks a lot Clinton,
> 
> I'm starting to understand how it works.  
> Should the query below be a rough equivalent of the previous one?
> 
> curl -XGET 'localhost:9200/test/item/\_search?pretty=true' -d '  
> {  
> "query": {  
> "bool": {  
> "should": [  
> {  
> "text": { "\_all": "I like iphone" }  
> },  
> {  
> "term": {  
> "\_all": {  
> "value": "iphone",  
> "boost": 5.0  
> }  
> }  
> }  
> ]  
> }  
> }  
> }'
> 
> btw are there any tricks to find out what lucene query I get after the  
> ES processing?
> 
> Thanks!
> 
> On Aug 30, 2:44 pm, Clinton Gormley [cl...@traveljury.com](mailto:cl...@traveljury.com) wrote:
> 
> > Hi Konstantin
> > 
> > > I want to increase a significancy for some terms in the query. E.g.  
> > > increase term 'iphone' in phrase 'I like iphone'.  
> > > The recipe i found so far is 'query\_string':
> > 
> > > {  
> > > "query": {  
> > > "query\_string": {  
> > > "query": "I like iphone^5.0"  
> > > }  
> > > }  
> > > }
> > 
> > > The first question is do I lose the 'analysis' for this query. I mean  
> > > if I set up stemmer will it work? Or for that kind of query the string  
> > > will be processed 'as is'.
> > 
> > The analysis will still work.
> > 
> > > And the second - Are there any better ways to do it? Mb I should use  
> > > boolean query with term boosting instead?
> > 
> > I would say yes, there are better ways. Trying to express your whole  
> > query in the lucene query string syntax becomes quite messy.
> > 
> > The query string syntax gets converted into multiple queries combined  
> > with bool and dismax queries anyway, so you can use the query DSL to  
> > combine queries with different boosts yourself
> > 
> > clint

---

<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, 3:55am UTC](https://discuss.elastic.co/t/query-terms-boosting/5277/5 "2017-07-06T03:55:32Z")

</div>


