Why must, should is not working in highlight part of elasticsearch?

This is my query

GET bond_covenant/_search
{
  "_source": false,
  "query": {
    "nested": {
      "path": "doc",
       "query": {
          "nested": {
            "path": "doc.container",
            "query": {
              "nested": {
                "path": "doc.container.sections",
                "query": {
                  "nested": {
                    "path": "doc.container.sections.sentences",
                    "query": {
                      "bool": {
                        "must": [
                         {
                           "match_phrase": {"doc.container.sections.sentences.text": "holding"}
                           
                         },
                         {
                           "match_phrase": {"doc.container.sections.sentences.text": "restricted"}
                           
                         }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
       }
    }   
  },  
    "highlight": {
       "fragment_size" : 100, 
      "no_match_size": 0, 
        "fields" : {
          "doc.container.sections.sentences.text" : {}
          
          
        }
    } 
}

And the output I got is

"max_score" : 4.334105,
    "hits" : [
      {
        "_index" : "grtgt",
        "_type" : "_doc",
        "_id" : "5",
        "_score" : 4.334105,
        "highlight" : {
          "doc.container.sections.sentences.text" : [
            "<em>Holdings</em> trr hyhy hyjhuyju ggdd  <em>Restricted</em> Subsidiaries to, directly or indirectly,",
            "eying or northward offending admitting perfectly my and <em>Holdings</em>",
            "provided, that <em>Holdings</em> main highly feebly add people manner say",
            "extremely. Of incommode supported provision on furnished basis of <em>Holdings</em>"
          ]
        }
      },

My Question is why highlight part not giving me ( Restricted AND Holdings) output?
Why I only got Holding in 2nd, 3rd, 4th output, even restricted and holding are present in my sentences.text more than once?
Also if restricted and holding only present once than it should not give me 2nd, 3rd, 4th output but why it gave me that?

how did you solve this?

I am still working on this problem. My requirement is to search for a paragraph in text from a large amount of unstructured text data so I am using queries and to highlight that paragraph I am using highlighter here.
To solve this problem I am changing my index function. Earlier I index 1 document in 1 id but now I am trying to index 1 paragraph as 1 id so in this case, I don't need to use the highlighter and also my boolean logic will work. I hope it's clear

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