is there an way to query the following using elasticsearch (version 2) :
indexed documents examples :
{_id=1 , "tags": [ "t1"]}
{_id=2 , "tags": [ "t1", "t2" ]}
{_id=3 , "tags": [ "t1", "t2", "t3" ]}
The following are query examples and expected results :
"tags": ["t1"] ---> document _ids=1
"tags": ["t1","t2"] ---> document _ids=1,2 (document #1 is expected too)
"tags": ["t1","t2","t3"] ---> document _ids=1,2,3
"tags": ["t2","t3"] ---> document _ids=NONE
"tags": ["t1","t3"] ---> document _ids=1 only
PUT my-index-000001/_doc/1
{ "tags": [ "t1"]}
PUT my-index-000001/_doc/2
{ "tags": [ "t1", "t2" ]}
PUT my-index-000001/_doc/3
{ "tags": [ "t1", "t2", "t3" ]}
The following query yield more than expected and include document #3 too in addition to #1
GET my-index-000001/_search
{
"query": {
"match": {
"tags": ["t1","t2"]
}
}
}
And on the following, document #3 is not matched but either the expected #1
GET metric_*/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"tags": "t1"
}
},
{
"match": {
"tags": "t2"
}
}
]
}
}
}
I need a way exclude any document that has tag value that is not exist in the query tag list
thanks in advance