Identify the KEY to which pattern got a match


#1
How do I make a similar query using QueryBuilders in Java? I am looking for a way to identify which key , the pattern got a matched. 

{
  "should": [
    {
      "match": {
        "description": {
          "query": "pattern",
          "_name": "description"
        }
      }
    },
    {
      "match": {
        "author": {
          "query": "pattern",
          "_name": "author"
        }
      }
    },
    {
      "match": {
        "headline": {
          "query": "pattern",
          "_name": "headline"
        }
      }
    }
  ]
}

As of now I am doing this in my Java code. I don't know how to add an identifier for the key ("like _name" in the above json") :slight_smile:

	QueryBuilder query = QueryBuilders.boolQuery()
							.should(QueryBuilders.matchQuery("description", sPattern))
                                                        .should(QueryBuilders.matchQuery("author", sPattern))
							.should(QueryBuilders.matchQuery("headline", sPattern));

(system) #2

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