I have a data available in ES in the below format. Lets call each json object as campaign object.
{id:"c1", tags:[{key:"k1",value:"v1"}, {key:"k2",value:"v2"}, {key:"k3",value:"v3"}]}
{id:"c2", tags:[{key:"k1",value:"v1"}, {key:"k4",value:"v4"}]}
{id:"c3", tags:[{key:"k5",value:"v5"}, {key:"k2",value:"v2"}]}
My client sends me the list of tag objects, i have to return the corresponding campaign objects to the client. For ex. 1st Example Req. -
[{key:"k1",value:"v1"}]
Res. -
{id:"c1", tags:[{key:"k1",value:"v1"}, {key:"k2",value:"v2"}, {key:"k3",value:"v3"}]}
{id:"c2", tags:[{key:"k1",value:"v1"}, {key:"k4",value:"v4"}]}
2nd Example Req. -
[{key:"k3",value:"v3"},{key:"k5",value:"v5"}]
Res. -
{id:"c2", tags:[{key:"k1",value:"v1"}, {key:"k4",value:"v4"}]}
{id:"c3", tags:[{key:"k5",value:"v5"}, {key:"k2",value:"v2"}]}
My service is written in spring boot, which es querybuilder(termsquery,nestedquery) should i use to achieve the same?
I tried this sample query , but it is returning empty list.
boolQueryBuilder.filter( QueryBuilders.termsQuery("tags", TAG_LIST));