Boosting results based on another field?


(Andy-2) #1

Hi,

I'm new to ElasticSearch, trying to see if I could migrate a website
from Solr to ES.

One of the features I need is to boost search results based on the
value of another field. All my documents have a field "popularity"
which is an integer. When a user makes a search, I want to return
results that are the best match but also take popularity into
account.

Right now in Solr when someone searches for "foo" I do something
like:

q={!boost b=log(popularity)}foo

which basically multiplies the "natural" scoring of a document with
the log of the popularity of that document.

Is it possible to do something similar in ElasticSearch?

Thanks.


(Clinton Gormley) #2

Hi Andy

Right now in Solr when someone searches for "foo" I do something
like:

q={!boost b=log(popularity)}foo

which basically multiplies the "natural" scoring of a document with
the log of the popularity of that document.

You can use a custom_score query to do this:

http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query.html

clint


(Andy-2) #3

Great! Thanks Clinton.

On Jun 2, 2:55 pm, Clinton Gormley clin...@iannounce.co.uk wrote:

Hi Andy

Right now in Solr when someone searches for "foo" I do something
like:

q={!boost b=log(popularity)}foo

which basically multiplies the "natural" scoring of a document with
the log of the popularity of that document.

You can use a custom_score query to do this:

http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-q...

clint


(system) #4