How to make matched_fields generic while highlighting - Elasticsearch


(Nikesh) #1

Hi all,

I am having duplicity in highlighting as few of my searches are matching in both .keyword and text field as well. So i am trying to employ "matched_fields" on all such fields.Problem is i don't know these fields at query time and there are too many such fields(around 100) which make my query very huge.

  "fields": {
      "field1": {
        "matched_fields": [
          "field1",
          "field1.keyword"
        ]
      },
    "field2": {
            "matched_fields": [
                   "field2",
                     "field2.keyword"
                      ]
      }
    }

Is there a way to make this generic? or is there any method that i can employ?