Reputation: 121
I am new to ES. I am having trouble finding exact phrase matches.
Let's assume my index has a field called movie_name. Let's assume I have 3 documents with the following values
If my search query is Mad Max, I want the first 2 documents to be returned but not the 3rd.
If I do the "not_analyzed" solution I will get only document 1 but not 2.
What am I missing?
Upvotes: 8
Views: 4471
Reputation: 121
I was able to do it using the following commands, basically create a custom analyzer, use the keyword tokenizer to prevent tokenization. Then use the analyzer in the "mappings" for the desired field, in this case "movie_name".
PUT /movie { "settings":{ "index":{ "analysis":{ "analyzer":{ "keylower":{ "tokenizer":"keyword", "filter":"lowercase" } } } } }, "mappings" : { "search" : { "properties" : { "movie_name" : { "type" : "string", "analyzer":"keylower" } } } } }
Upvotes: 4
Reputation: 3094
Use Phrase matching like this :
{
"query": {
"match_phrase": {
"movie_name": "a"
}
}
}
Upvotes: 0