Custom query with advanced scoring


(John) #1

Hello,

I have a job board and I want to improve my Search results.
This is my columns: title, description company_name, priority, created_at, expired_at

I was looking for long time to find a way to improve my results and this is what I think will be fine:

  • Filter by keywords with Title^4, company_name^2, description
  • "priority" should increase the _score
  • "created_at" should decrease the _score with age

This is my query but it doesn't return what I was expecting, it looks like the "filter" doesn't works. My first results is a recent record but nothing related to what I was searching.

{
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "query": "sales",
            "fields": [
              "title^4",
              "company_name^2",
              "description"
            ],
            "fuzziness": 1
          }
        }
      ],
      "minimum_should_match": 1,
      "should": [
        [
          {
            "bool": {
              "must_not": {
                "exists": {
                  "field": "expired_at"
                }
              }
            }
          },
          {
            "range": {
              "expired_at": {
                "gte": "2018-11-07 22:01:22"
              }
            }
          }
        ]
      ],
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "__soft_deleted": 0
              }
            },
            {
              "terms": {
                "languages": [
                  "fr"
                ]
              }
            }
          ]
        }
      }
    }
  },
  "sort": [
    {
      "priority": "desc"
    },
    {
      "created_at": "desc"
    },
    {
      "_score": "desc"
    }
  ]
}

If you have some suggestion to help me to improve this, I'll be glad to have you advice

Thank you


(system) #2

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