Function_score multi field filters together

this is sample collection that's I want to sort result per custom score in elastic search in so try to read documents so founded function score do it for me
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

enter image description here
I have got searching like below and It works properly.
this code sort list Based on Score

{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
          { "match_all": { }}
          ],
          "must_not": [],
          "should": []
        }
      },
      "boost": "5",
      "functions": [
        {
          "filter":{
            "term": {
                "soldier": "0"
              }
          }, "weight": 4
        },
           {
          "filter":{
            "term": {
                "married": "0"
              }
          }, "weight": 3
        }
    
      ],
      "score_mode": "sum"
    }
  }
}

But I want filter soldier and married altogether and have one weight for both of them.
such as below but It works wrong and does't sort return data Base on score
Do you have any idea ?what is it solution for logical and between filter and set one weight for them?

thank you please help me

   {
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
          { "match_all": { }}
          ],
          "must_not": [],
          "should": []
        }
      },
      "boost": "5",
      "functions": [
        {
          "filter": [
            {
              "term": {
                "soldier": "0"
              }
            },
            {
              "term": {
                "married": "1"
              }
            }
          ],
          "weight": 4
        }
      ],
      "score_mode": "sum"
    }
  }
}

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