I am having an issue to return a good suggestion on misspelled Ngrams. Lets me explain in details.
Consider the following mapping with a shingle filter on 'title' field:
PUT _template/test_news_flo
{
"template": "test_articles_flo",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 2,
"analysis": {
"filter": {
"filter_shingle":{
"type":"shingle",
"max_shingle_size":5,
"min_shingle_size":2,
"output_unigrams":"true"
}
},
"analyzer": {
"analyzer_shingle":{
"tokenizer":"standard",
"filter":["standard", "lowercase", "filter_shingle"]
}
}
}
},
"mappings": {
"article": {
"_all": { "enabled": false },
"properties": {
"title": {
"norms": {
"enabled": false
},
"type": "string",
"fields": {
"shingle": {
"search_analyzer":"analyzer_shingle",
"index_analyzer":"analyzer_shingle",
"type":"string"
}
}
}
}
}
}
}
Add one document containing 'carla bruni' into the index test_articles_flo
POST /test_articles_flo/article
{
"title": "Carla Bruni scintillante pour le Sidaction"
}
Then run the following suggest phrase query:
POST /test_articles_flo/_search/?size=0
{
"suggest": {
"suggest-phrase-title": {
"text": "Carla bruno",
"phrase": {
"field": "title.shingle",
"confidence": 1,
"size": 5,
"gram_size": 2,
"max_errors": 2
}
}
}
}
The following result is returned, which is exactly what I need:
{
"text": "Carla bruno",
"offset": 0,
"length": 11,
"options": [
{
"text": "carla bruni",
"score": 0.24166171
}
]
}
Now add another article :
POST /test_articles_flo/article
{
"title": "Le réveil de Massimo Bruno"
}
Then search again with the suggest: No suggestion is given as 'bruno' is found in the index and elasticsearch considers it as valid.
Do you know how could I make the suggest return 'carla bruni' as a suggestion ?