So I have this index
{
"settings":{
"index":{
"number_of_replicas":0,
"analysis":{
"analyzer":{
"default":{
"type":"custom",
"tokenizer":"keyword",
"filter":[
"lowercase",
"my_ngram"
]
}
},
"filter":{
"my_ngram":{
"type":"nGram",
"min_gram":2,
"max_gram":20
}
}
}
}
}
}
and I'm performing this search through the tire gem
{
"query":{
"query_string":{
"query":"xyz",
"default_operator":"AND"
}
},
"sort":[
{
"count":"desc"
}
],
"filter":{
"term":{
"active":true,
"_type":null
}
},
"highlight":{
"fields":{
"name":{
}
},
"pre_tags":[
"<strong>"
],
"post_tags":[
"</strong>"
]
}
}
and I have two posts that should match named 'xyz post' and 'xyz question'
When I perform this search, I get the highlighted fields back properly
<strong>xyz</strong> question
<strong>xyz</strong> post
Now here's the thing ... as soon as I change min_gram to 1 in my index and
reindex. the highlighted fields start coming back as this
<strong>x</strong><strong>y</strong><strong>z</strong>
posxyzt
xyz
questioxyzn
I simply cannot understand why.
--