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

**URL:** <https://discuss.elastic.co/t/how-to-build-querybuilder-to-search-for-the-map-of-entrys-in-elasticsearch-index/323469>\
**Category:** Elasticsearch\
**Created:** [January 19, 2023, 4:40am UTC](https://discuss.elastic.co/t/how-to-build-querybuilder-to-search-for-the-map-of-entrys-in-elasticsearch-index/323469 "2023-01-19T04:40:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SandhyaRani](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@SandhyaRani](https://discuss.elastic.co/u/SandhyaRani)\
**Post date:** [January 19, 2023, 4:40am UTC](https://discuss.elastic.co/t/how-to-build-querybuilder-to-search-for-the-map-of-entrys-in-elasticsearch-index/323469/1 "2023-01-19T04:40:10Z")

</div>

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

```auto
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

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

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

```

And wanted to query with the map `props'

```auto
"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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 16, 2023, 4:41am UTC](https://discuss.elastic.co/t/how-to-build-querybuilder-to-search-for-the-map-of-entrys-in-elasticsearch-index/323469/2 "2023-02-16T04:41:08Z")

</div>

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