I work on a project that uses elasticsearch 5.2. The code is in java and I use elasticsearch java client 5.2.
In this project, I have a field called hash, a 7-character code containing uppercase letters, lowercase letters, and numbers (in English language). I want to do two searches on this field:
check the existence of a hash
"ErTg1Qh"(case sensitive)find hashes that sub string s contains in them (for example, sub string
"tg"exist in the hash"ErTg1Qh").
For the hash field, I chose the keyword datatype.
I used matchQuery function for first search as below:
String hash = "ErTg1Qh";
QueryBuilders.matchQuery("hash", hash)
and queryStringQuery function for the second search as below:
queryString = "hash:*" + subString + "*";
QueryBuilders.queryStringQuery(queryString)
but, the second one does not work properly.
How can I handle these two kinds of search on a field?