So i just created a new index to search for a string which starts with some specific characters like 'Kibana*' (just like 'Kibana%' in SQL) which means it should return results with text "Starting with" Kibana and not "Contains" Kibana,, for that i specified an anaylzer for my field "business"
Here is my new index mapping:
PUT stg_sdmr_three
{
"settings": {
"analysis": {
"analyzer": {
"analyzer_startswith": {
"tokenizer": "keyword",
"filter": "lowercase"
}
}
}
},
"mappings" : {
"_doc" : {
"properties" : {
"@version" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"business" : {
"type" : "text",
"analyzer" : "standard",
"search_analyzer" : "analyzer_startswith",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 120
}
}
}
}
}
}
}
Sample Data for searching:
PUT stg_sdmr_three/_doc/1
{
"@version" : "1",
"business" : "Jeff Nomura "
}
PUT stg_sdmr_three/_doc/2
{
"@version" : "1",
"business" : "HORIKAWAYA NOMURA "
}
PUT stg_sdmr_three/_doc/3
{
"@version" : "1",
"business" : "NOMURA CONSULTING "
}
now i am getting all three results in response,, where i want only the third one
"NOMURA CONSULTING" , as its starts with "nomura"
Here is my query :
{
"query": {
"prefix": {
"business": "nomura"
}
}
}
i have tried prefix, match_phrase_prefix & wildcard also but nothing helps