How to build QueryBuilder to search for the map of entry's in ElasticSearch index

I would need queryBuilder to search the index with entire map of values and return documents only if all map values matched in ES index.

I could do for set of values like below

val sampleSet = setOf("foo", "bar")

val query = NativeSearchQueryBuilder()
           .withQuery(
               QueryBuilders.termsQuery(
                   "identifiers.endpointId.keyword", sampleSet)
            )
            .build()

But wanted to search with map of values.
For example
I index below documents in ES

 1. {
      "timestamp": 1601498048,
      "props": {
        "cp1": "cv1",
        "cp2": "cv2"
      }
    }

2. {
      "timestamp": 1601498098,
      "props": {
        "key1": "v1",
        "key2": "v2"
      }
    }

And wanted to query with the map `props'

"props" 
  {
     "cp1": "cv1",
     "cp2": "cv2"
 }

and return documents only for the entire matched map values. So in this case the result would be only first document, since it matched the given props.

How to build queryBuilder with map of values. Any suggestions?

Thanks!

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