0

I have an example shopping app, i want to create searching page using elasticsearch, when user search for specific product for example "Iphone" then display all iphone products. But, i want to promote product to show on top of search result. It's more like promoting product, when i promote for specific product then it shows at the top of search results.

How can this achieve by elasticsearch?

andrey_derma
  • 43
  • 1
  • 6

1 Answers1

0

In the Elasticsearch there are many documentation on how to achieve this due it's a typical need on searchers. I will suggest you trying to make your own boosting relevance function.

Like:

{
  "query": {
    "function_score": {
      "filter": { 
        "term": { "content": "mobile" }
      },
      "functions": [ 
        {
          "filter": { "term": { "brand": "Apple" }}, 
          "weight": 4
        }
      ],
      "score_mode": "sum", 
    }
  }
}

Here the documentation up to date: FunctionScoring

Also as a tip, might be absolutely worth to take a look to Relevance chapter and understand how ES tries to order your results by relevance.

jordivador
  • 1,016
  • 11
  • 26