My edge-ngram solution does not return any results for the following search:
"10th A"
Where 3 documents exist with the field values:
"10th Avenue, Red Beach, New Zealand",
"4 10th Avenue, Red Beach, New Zealand",
"2 10th Avenue, Red Beach, New Zealand"
Query:
POST /addresses_nz/_search?pretty
{
"_source": [
"search_name"
],
"size": 10,
"query": {
"bool": {
"must": [
{
"match": {
"search_name.autocomplete": {
"query": "10th A",
"operator": "and",
"fuzziness": 0
}
}
}
],
"should": [
{
"prefix": {
"search_name.exact": {
"value": "10th A"
}
}
}
]
}
}
}
Index Mappings:
{
"addresses_nz" : {
"mappings" : {
"properties" : {
"search_name" : {
"type" : "text",
"fields" : {
"autocomplete" : {
"type" : "text",
"analyzer" : "autocomplete_index",
"search_analyzer" : "autocomplete_search"
},
"exact" : {
"type" : "keyword"
}
}
}
}
}
}
}
Index Settings:
{
"addresses_nz" : {
"settings" : {
"index" : {
"analysis" : {
"filter" : {
"english_stopwords" : {
"type" : "stop",
"stopwords" : "_english_"
}
},
"analyzer" : {
"autocomplete_index" : {
"filter" : [
"lowercase",
"english_stopwords"
],
"type" : "custom",
"tokenizer" : "autocomplete_index"
},
"autocomplete_search" : {
"tokenizer" : "standard"
}
},
"tokenizer" : {
"autocomplete_index" : {
"token_chars" : [
"digit",
"letter"
],
"min_gram" : "1",
"type" : "edge_ngram",
"max_gram" : "15"
}
}
}
}
}
}
}