Hi,
I have a question regarding the requirement in elastic-search. I have following documents in my index.
{
"name":"a1",
"userId": 1,
"tag":"tag1"
},
{
"name":"abc",
"userId":1,
"tag":"tag2"
},
{
"name":"a2",
"userId":2,
"tag":"tag1"
},
{
"name":"abc2",
"userId":2,
"tag":"tag2"
},
{
"name":"abc3",
"userId":2,
"tag":"tag3"
}
Now if my query is to fetch me all the documents for the userID who has tag values as "tag1" AND "tag3" i.e. in this case documents returned are
{
"name":"a2",
"userId":2,
"tag":"tag1"
}
{
"name":"abc3",
"userId":2,
"tag":"tag3"
}
so in this case document containing tag values as "tag1" but for userId 1 will not be returned as for that userID we do not have document for "tag3".
I was checking whether aggregation pipeline or groovy script would work however I am stuck. So can you please suggest what elastic query would be required for this.
In Future there might be requirement similar to AND I might have to work on NOT i.e. " tag2 NOT tag3 " then I have to show only
{
"name":"abc",
"userId":1,
"tag":"tag2"
}