Reputation: 9303
Am new to elastic search, this is my query to find a exact match in my collection.
{
"query": {
"filtered": {
"query": {
"match": {
"_id": {
"query": "1"
}
}
},
"filter": {
"term" : {
"team_id":"2",
"created_user":"099"
}
}
}
}
}
By running this query I am getting one record, but my problem is its not matching "team_id" filed. When I change team_id to some other value eg: 4, I am still getting the record with team_id = 2, Please help me to write an elastic search query with three fields. Thanks
Upvotes: 0
Views: 3862
Reputation: 15550
If you want exact match, be sure that fields that you want to make search operation must be not_analyzed. And it seems you are using multiple case in your filter. You can refactor your query by using and filter like;
{
"query": {
"filtered": {
"query": {
"match": {
"_id": {
"query": "1" // remember that, this will always return one result. Update here according to your needs. For example, use tag instead of _id like tag=responsive in order to get results that matches tag field with responsive
}
}
},
"filter": {
"and": [
{
"term": {"team_id":"2"}
},
{
"term": {"created_user":"099"}
}
]
}
}
}
Upvotes: 1