Easiest way to boost field value?

hello,

what is the easiest way to boost field in TextQuery? lets say i have two
documents:

{'title': 'string1', description: ''}
{'title': 'string2', description: 'string1' }

and i want to find documents where title OR description contains
'string1', but matches in 'title' attribute should have higher score
than 'description'?

tk

You can associate a boost value with a query:

{
"text" : {
"desc" : {
"query" : "text here",
"boost" : 5.0f
}
}
}

Another option is to wrap the query in a custom_boost_query (Elasticsearch Platform — Find real-time answers at scale | Elastic) which simply multiplies the wrapped query by the custom boost factor.

On Monday, February 27, 2012 at 11:54 AM, Tomasz Kloc wrote:

hello,

what is the easiest way to boost field in TextQuery? lets say i have two
documents:

{'title': 'string1', description: ''}
{'title': 'string2', description: 'string1' }

and i want to find documents where title OR description contains
'string1', but matches in 'title' attribute should have higher score
than 'description'?

tk

Thanks Shay, I ended up with query like this:

{'query':
{ 'bool':
{ 'should':
[
{'text': {'title': {'query': 'my querystring', 'operator': 'and',
'boost': 5 } } },
{'text': {'description': { 'query': 'my querystring', 'operator':
'and', 'boost': 1 } } }
]
}
}
}

On 27.02.2012 14:12, Shay Banon wrote:

You can associate a boost value with a query:

{
"text" : {
"desc" : {
"query" : "text here",
"boost" : 5.0f
}
}
}

Another option is to wrap the query in a custom_boost_query
(Elasticsearch Platform — Find real-time answers at scale | Elastic)
which simply multiplies the wrapped query by the custom boost factor.

On Monday, February 27, 2012 at 11:54 AM, Tomasz Kloc wrote:

hello,

what is the easiest way to boost field in TextQuery? lets say i have two
documents:

{'title': 'string1', description: ''}
{'title': 'string2', description: 'string1' }

and i want to find documents where title OR description contains
'string1', but matches in 'title' attribute should have higher score
than 'description'?

tk