I am newbie to elastic search.So i have a scenario like
i have a values like...
cricket, cricketab, cricketbcd, cricketcd, crazy, my fav game is cricket, cricket king, cricbuzzz, cricket is universal game, anu likes cricket
So when i search with 'cricket'.The result should be like
cricket
cricketab
cricketbcd
cricketcd
cricket king
cricket is universal game
anu likes cricket
my fav game is cricket
And when i search with cr.The result should be like
crazy
cricbuzz
cricket
cricketab
cricketbcd
cricketcd
cricket king
cricket is universal game
anu likes cricket
my fav game is cricket
So i created index like
curl -XPUT 'x.x.x.x:9200/index_like?pretty' -H 'Content-Type: application/json' -d'
{
"settings": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 100
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
},
"mappings": {
"type_like": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "text",
"analyzer": "keyword"
}
}
},
"count": {
"type": "integer"
}
}
}
}
}
'
and i queried like
curl -XGET 'x.x.x.x:9200/index_likes_test/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"should": [
{
"term": {
"name.keyword": {
"value": "cricket"
}
}
},
{
"match_phrase": {
"name": {
"query" : "cricket"
}
}
},
{
"match": {
"name": {
"query": "cricket"
}
}
},
{
"match_phrase_prefix": {
"name": {
"query" : "cricket"
}
}
}
]
}
}
}
'
So i am getting exact match first.but i didn't get the result as like above
I hope u understand my scenario.There should be exact match first in the result if exact match exists.Followed by alphabetical sorting values..
Thank u