Query terms boosting


(konstantin) #1

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.


(Clinton Gormley) #2

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


(konstantin) #3

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 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


(Shay Banon) #4

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.comwrote:

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 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


(system) #5