How to use queryString() in elasticsearch (java API)?
elasticsearch, java
Solution
You can put quotes around the string to do an exact match:
QueryBuilders.queryString("\"4r5etgg-kogignjj-jdjuty687-ofijfjfhf-kdjudyhd\"");
If you don't want partial matches on the above string index an untokenized version of the value and search on that. In you mapping add:
"token": {
"type": "multi_field",
"fields": {
"untouched": {
"type": "string",
"index": "not_analyzed"
}
}
}
Then search:
{
"query": {
"match": {
"token.untouched": "4r5etgg-kogignjj-jdjuty687-ofijfjfhf-kdjudyhd"
}
}
}
Problem
I am working on elastic-search v1.1.1 I faced a problem with search queries .I want to know How solve below obstacle Here is my mapping ``` { "token" : { "type" : "string" } } ``` Data in indexed record is ``` { token : "4r5etgg-kogignjj-jdjuty687-ofijfjfhf-kdjudyhd" } ``` My search is ``` 4r5etgg-kogignjj-jdjuty687-ofijfjfhf-kdjudyhd ``` I want exact match of the record ,which query I need to use to get exact match of the record can it be done ``` QueryBuilders.queryString() ? ``` I checked with queryString() ,then I finalized its not useful for exact match Please suggest me