Setting up Elasticsearch _score based on the field value in relation to another field value of the corresponding document

We are updating our search engine from Solr to Elasticsearch. We have already improved a lot of things, but something still did not work out, it is increasing the rating of the document (product) by the popularity of the product (this is an e-commerce website).

This is what we currently have (with lots of irrelevant bits):

{
    "query": {
        "function_score": {
            "query": {
                "multi_match" : {
                    "query":    "renal dog food",
                    "fields": [ "family_name^20", "parent_categories^2", "description^0.2", "product_suffixes^8", "facet_values^5" ],
                    "operator":   "and",
                    "type":       "best_fields",
                    "tie_breaker": 0.3

                }
            },
            "functions": [{
                "script_score": {
                    "script": "_score * log1p(1 + doc['popularity_score'].value)"
                }
            }],
            "score_mode": "sum"
        }
    },
    "sort": [
        { "_score": "desc" }
    ],
}

The field popularity_scorecontains the total number of orders containing this item in the last 6 weeks. Some items will never be ordered, and some will have 30,000 (with potentially much more as we continue to grow our business). This is a fairly large range.

, () , . , , , . , , - popularity_score popularity_score , (log1p ). - ?

!

+4

Source: https://habr.com/ru/post/1539129/


All Articles