"Hierarchical" search of a value

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 ?

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