Help with function_score

Thanks alot for your response. I'm sorry for I could not replay earlier.

You probably want to make it a not_analyzed field if you are using it for term queries?

Yes, you are absolutly correct. It's my mistake with the mapping.

After some searches and experiments I got something like this:

{
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "filter": [
              {
                "missing": {
                  "field": "deleted_at"
                }
              },
              {
                "range": {
                  "created_at": {
                    "lt": "now"
                  }
                }
              },
              {
                "term": {
                  "ad_type": "sell"
                }
              }
            ]
          }
        },
        {
          "function_score": {
            "functions": [
              {
                "exp": {
                  "updated_at": {
                    "decay": 0.33,
                    "scale": "12w"
                  }
                }
              }
            ],
            "query": {
              "match": {
                "text": "search phrase"
              }
            }
          }
        }
      ]
    }
  },
}