Match query with best match at top

Hello ,

I am having real difficulty getting best matches at top.
Here's a sample of my document

  {
           "_index": "finished_goods",
           "_type": "_doc",
           "_id": "1",
           "_score": 1,
           "_source": {
             "balance": 100,
             "created": "2021-01-05T06:42:44",
             "updated": "2021-01-05T06:42:44",
             "title": "Bagru Print",
             "description": "",
             "sku": "1",
             "qty": 100,
             "product_category": "run",
             "fabric_combination": "f60",
             "print_technique": "bgr",
             "design_number": "mix",
             "gen_name": "run/f60/bgr/mix/n.a/1"
           }
         }, 

Now I need to get the best matches with top most priority to gen_name and then all the other fields.

Here is my current query

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "gen_name": "query"
          }
        },
        {
          "query_string": {
            "query": "*query*",
            "fields": [
              "*"
            ]
          }
        }
      ],
      "must": [
        {
          "range": {
            "balance": {
              "gte": "more_than",
              "lte": "less_than"
            }
          }
        }
      ],
      "must_not": [
        {
          "match": {
            "balance": "0"
          }
        }
      ]
    }
  },
  "sort": [
    {
      "field": {
        "order": "sort_by"
      }
    }
  ],
  "from": "page",
  "size": "per_page"
}

But it is not getting correct matches. Help is very very much appreciated.
Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.