I have a problem i know is definitely not unique, but I am trying to figure what is the smartest way to do this.
I have a name field in my index "name"
the data in it could be
John Doe
john doe
JOHN DOE
doe JOHN
john mathew doe
any such, I need to run a search on the words john and doe and get all these results. Whats the best way to do this and can I do this with the keyword field or text is the only option?
Currently, I am trying to work with match option. Is there a smarter way to do it?
Any time you think of "any/some of the words" as part of a requirement, it means it's text that's going to need to be tokenized into words, which means you're going to want the text type.
Any time you think of "must match the value in the field exactly," then you probably don't need tokenization and therefore keyword is likely a better match.
As some extensions to those that tend to come up next:
If you want to match a phrase within a bigger chunk of text (e.g. match "brown fox" exactly within quick brown fox jumps) you still want text, but you may want to start looking at the phrase queries in Elasticsearch
If you just want to be case insensitive but otherwise match a field value exactly, you can use a keyword with a normalizer
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.