Elasticsearch DSL queries : how to handle search if some documents doesn't have the specific field

Hi,
I have documents that have not same structure, I mean some of my documents have some fields that other doesn't, so I want to search in those fields that may or may not exists..
I wrote a bool query with filter and must_not combination, but it doesn't return to me anything! I Wrote another query like that on another field that almost exists and the results are what I expected.. so I know the query is ok! but if you know another solution can share that with me?
thanks with advanced..

PS: this is part of my query:

body:  [
   "query" => [
      "bool" => [
        "must" => [
          [
              "query_string" => [
              "query" => "sales"
              "boost" => 1
           ]
        ]
      ]
      "must_not" => []
      "filter" => [
        [
            "bool" => [
               "must_not" => [
                  [ "term" => ["professional_experience.location_id" => 1]]
               ]
            ]
        ],
        [
           "bool" => [
               "must_not" => [
                  [ "term" => ["educations.location_id" => 1]]
              ]
           ]
         ]
      ]
    ]
  ]
]

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