This method is extremely slow, but if you've tokenized your fields in a certain way and don't want to re-index them to include exact matches, this is a good way to go.
{
"query" : {
"filtered" : {
"query" : {
"match_all": {}
},
"filter" : {
"script" : {
"script" : "_source.name == filename",
"params" : {
"filename" : "exact_match_value.txt"
}
}
}
}
}
}
What's happening here is that we've included a query to match everything, and then we're filtering the query based on the script. The field that I was looking for did't appear in the actual Elasticsearch document, but it was in a field in the _source, which is why we're using that here. The keys in params can be whatever you want, as long as they appear in the value of the script field.