Luke LaFountaine
Luke LaFountaine

Reputation: 848

Modifying relevance score in elasticsearch using results from another query

A project I am working on utilizes elasticsearch as a search engine. I also am using a graph database to keep track of user actions and the relationships between queries, clicks, etc.

What I want to do is index queries and their top results from the graph database into elasticsearch, so at query time, I can boost the elasticsearch _score by the score provided by the graph database. Is this possible in elasticsearch itself? Or do I need to do the boosting externally?

Upvotes: 1

Views: 1714

Answers (2)

macebalp
macebalp

Reputation: 186

If i understad your problem, you have your primary results comming from another source (graph DB) and that score is highly dependent of every query as it is with Elasticsearch. Script score functions in ES are not suited for this task, as you have limited parameters to pass to it besides accessing all indexed document's fields. So the only choices I can see are:

  1. Index the primary results including the external score and then perform a query using the above mentioned script score or simpler function score. Note that besides obvious efficiency drawbacks(indexing load on ES, roundtrips, etc), this index will contain only a subset of documents and it will highly affect the relevancy of the terms.
  2. Filter an ES index and combine the result externally calculating whichever new score fits you. I would advice this one, note that if you want to get only documents found by first query you should try to filter by their ids like this or like this depending on your version, so the ES score is only made up of the terms you wanted to look for and their relevance.

Upvotes: 2

Hugo
Hugo

Reputation: 254

boost the elasticsearch _score by the score

You can boost the score of the documents during elasticsearch query using the function score query.

Upvotes: 0

Related Questions