[Highlight] Highlight query doesn't work properly in should query

GET naver_article/_search
{
  "size": 100,
  "query" : {
    "function_score": {
      "functions": [
        {
          "weight": 1.8,
          "gauss": {
            "format_date": {
              "scale": "1d"
            }
          }
        },
        {
          "weight": 1.5,
          "gauss": {
            "format_date": {
              "scale": "7d"
            }
          }
        },
        {
          "weight": 1.25,
          "gauss": {
            "format_date": {
              "scale": "1m"
            }
          }
        },
        {
          "weight": 1.1,
          "gauss": {
            "format_date": {
              "scale": "6m"
            }
          }
        },
        {
          "weight": 1,
          "gauss": {
            "format_date": {
              "scale": "36m"
            }
          }
        }
      ],
      "query": {
        "bool": {
          "should": [
            {
              "terms": {
                "title": [
                  "EV",
                  "XeV",
                  "electric vehicle",
                  "fcev",
                  "fuel cell electric vehicle"
                ],
                "boost": 3
              }
            },
            {
              "terms": {
                "main_content": [
                  "EV",
                  "XeV",
                  "electric vehicle",
                  "fcev",
                  "fuel cell electric vehicle"
                ],
                "boost": 3
              }
            },
            {
              "terms": {
                "title": [
                  "Arrow Electronics",
                  "Fortis",
                  "HubSpot",
                  "Boston Properties REIT",
                  "Sturm Ruger",
                  "Pennsylvania Real Estate Investment Trust",
                  "Ambarella",
                  "Healthequity",
                  "Horizon Bancorp",
                  "Duke Energy",
                  "Equinor ADR Representing",
                  "Aptiv",
                  "Pure Storage Class A",
                  "Harmony Gold Mining ADR Representing 1",
                  "Whiting Petroleum",
                  "Citizens Class A",
                  "Intel Corporation",
                  "QUALCOMM",
                  "Baidu ADR Reptg 1/10 Class A",
                  "NXP Semiconductors",
                  "Yandex Class A",
                  "Alphabet Class A",
                  "Financial Institutions",
                  "Akebia Therapeutics",
                  "National CineMedia",
                  "Heat Biologics",
                  "Orgenesis",
                  "Codorus Valley Bancorp",
                  "Protective Insurance Class B",
                  "Citizens Community Bancorp",
                  "Energy Transfer Units",
                  "scPharmaceuticals",
                  "EyePoint Pharmaceuticals",
                  "Everspin Technologies",
                  "Orion Energy Systems",
                  "Harrow Health"
                ],
                "boost": 1.2
              }
            },
            {
              "terms": {
                "main_content": [
                  "Arrow Electronics",
                  "Fortis",
                  "HubSpot",
                  "Boston Properties REIT",
                  "Sturm Ruger",
                  "Pennsylvania Real Estate Investment Trust",
                  "Ambarella",
                  "Healthequity",
                  "Horizon Bancorp",
                  "Duke Energy",
                  "Equinor ADR Representing",
                  "Aptiv",
                  "Pure Storage Class A",
                  "Harmony Gold Mining ADR Representing 1",
                  "Whiting Petroleum",
                  "Citizens Class A",
                  "Intel Corporation",
                  "QUALCOMM",
                  "Baidu ADR Reptg 1/10 Class A",
                  "NXP Semiconductors",
                  "Yandex Class A",
                  "Alphabet Class A",
                  "Financial Institutions",
                  "Akebia Therapeutics",
                  "National CineMedia",
                  "Heat Biologics",
                  "Orgenesis",
                  "Codorus Valley Bancorp",
                  "Protective Insurance Class B",
                  "Citizens Community Bancorp",
                  "Energy Transfer Units",
                  "scPharmaceuticals",
                  "EyePoint Pharmaceuticals",
                  "Everspin Technologies",
                  "Orion Energy Systems",
                  "Harrow Health"
                ],
                "boost": 2.5
              }
            }
          ]
        }
      },
      "score_mode": "sum",
      "boost_mode": "multiply"
    }
  },
  "highlight": {
    "fields": {
      "main_content": {
        "type" :"unified",
        "boundary_scanner": "word",
        "fragment_size": 1,
        "number_of_fragments": 10,
        "pre_tags": [
          "<>"
        ],
        "post_tags": [
          "</>"
        ]
      }
    }
  },
  "collapse": {
    "field": "aid"
  }
}

I want to get docs with highlighted terms list.
If terms "A","B" belong to some document "C", I want search result include "C" document and highlighted with "A" and "B".

Unfortunately, above query doesn't work well. Sometimes they find documents but anything didn't highlighted, or sometimes they only capture one of terms list in highlight.
(It should capture multiple terms in document!)

It is very confused to me, Because I checked documents using term_vector API , to verify this documents's analyzed vectors possible. In term vector in documents is correct, only strange things is highlight feature.

Q1. How can I get proper multiple terms in highlight ?
Q2. I want to know number of count terms each document after search query. Is it possible to count every terms after search?

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