# "Hierarchical" search of a value

**URL:** <https://discuss.elastic.co/t/hierarchical-search-of-a-value/191808>\
**Category:** Elasticsearch\
**Created:** [July 23, 2019, 12:26pm UTC](https://discuss.elastic.co/t/hierarchical-search-of-a-value/191808 "2019-07-23T12:26:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chevreau\_de\_guerre](https://avatars.discourse-cdn.com/v4/letter/c/a6a055/32.png) [@Chevreau\_de\_guerre](https://discuss.elastic.co/u/Chevreau_de_guerre)\
**Post date:** [July 23, 2019, 12:26pm UTC](https://discuss.elastic.co/t/hierarchical-search-of-a-value/191808/1 "2019-07-23T12:26:40Z")

</div>

Hello everyone !

Here is a sample of my data :

```
{
      "_index":"blabla",
      "_source":{
         "idUser":"123456",
         "name":[
            "name.id"
         ],          
         "attributeA":"A",
         "attributeB":"B",
         "@timestamp":"2019-07-23T08:42:57.717Z",
         "content":{
            "typeA":{
               "typeB":{
                  "TARGET":"This is the value I search XYZ123 bla bla",
                  "otherStuff":"lalala"
               },
               "subAttributeA":"AAA"
            }
         },
      }
   }

```

I need to search elasticsearch datas from java. I am using Querybuilders library.  
I need to search every data that has "XYZ123" in "TARGET" field.

I could use : QueryBuilders.wildcardQuery("content.typeA.typeB.TARGET","_XYZ123_");

But the problem is : my data doesn't always follow this hierarchy. I don't know how many types there will be between "content." and ".TARGET". Sometimes there is none, sometimes more ...

So here is my question : is there a way to just search every data samples that has a field "TARGET" with the value "_XYZ123_" in the content block ?

---

<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:** [August 20, 2019, 12:26pm UTC](https://discuss.elastic.co/t/hierarchical-search-of-a-value/191808/2 "2019-08-20T12:26:49Z")

</div>

Closed on August 20, 2019, 12:26pm UTC

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