Nitesh
Nitesh

Reputation: 276

How to Boost The relevance dynamically(boost value get from database) in Tire elasticsearch

if the search term provided by an end user contains any of the words or phrases (but does not need to be an exact match) contained in the Decrease_Relevance_Text field, then the relevance for that specific product is decreased by the amount in the Decrease_Relevance_Points

Upvotes: 0

Views: 244

Answers (2)

Nitesh
Nitesh

Reputation: 276

should do
 custom_score :script => "_score+doc['increase_relevance_points'].value" do
  boolean do
    should { match :increase_relevance_text, term}
  end
 end
end

Upvotes: 0

ramseykhalaf
ramseykhalaf

Reputation: 3400

You can use the boosting query (official docs here)

{
    "boosting" : {
        "negative" : {
            "match" : {
                "your_field" : "decrease_relevance_text"
            }
        },
        "negative_boost" : decrease_relevance_points
    }
}

I don't know how to create this specifically with tire though, maybe someone else can help you.

Upvotes: 1

Related Questions