How is it possible to get term suggestions by prefix, I have the name field.
I have three records:
sitting in the mid of the place
making the minimum job done
canal mib gone
I want to be able to get the word minimum as a suggested term when I type min but I do get mid and mib which are in the other documents.
This is my query:
{
"suggest": {
"text": "min",
"simple_phrase": {
"term": {
"analyzer": "standard",
"field": "Name.raw",
"min_word_length": 2,
"prefix_length": 1,
"suggest_mode": "always"
}
}
}
}
MAPPING:
{
"Name": {
"type": "text",
"index": "not_analyzed",
"include_in_all": true,
"fields": {
"raw": {
"type": "text",
"index": "not_analyzed",
"include_in_all": false
},
"trigram": {
"type": "text",
"analyzer": "trigram_analyzer"
}
}
}
}
RESULT
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": 0,
"hits": []
},
"suggest": {
"simple_phrase": [
{
"text": "min",
"offset": 0,
"length": 3,
"options": [
{
"text": "mib",
"score": 0.6666666,
"freq": 79
},
{
"text": "mid",
"score": 0.6666666,
"freq": 59
}
]
}
]
}
}