Prefix query is case sensitive despite both index and search analyzers using lowercase filter?


(Ifo20) #1

Full question can also be found here https://stackoverflow.com/questions/50368459/why-is-my-elastic-search-prefix-query-case-sensitive-despite-using-lowercase-fil

Essentially I am using a prefix query on the Name.raw field (which is indexed using the keyword tokenizer with a lowercase token filter) and searching for 'harry' gets my result 'Harry Potter' but 'Harry' doesn't.

The search_analyzer I am using is also using the lowercase filter, so shouldn't the query for 'Harry' be the same as the query for 'harry'?

Mapping:

{
"autocomplete_tenant_1": {
"mappings": {
"pages": {
"properties": {
"Id": { "type": "keyword" },
"Name": {
"type": "text",
"fields": {
"raw": {
"type": "text",
"analyzer": "keywordAnalyzer",
"search_analyzer": "pageSearchAnalyzer"
}
},
"analyzer": "pageSearchAnalyzer"
},
"Routes": {
"properties": {
"CultureCode": {
"type": "keyword"
},
"Domain": {
"type": "long"
},
"Path": {
"type": "keyword"
},
"PointOfSale": {
"type": "long"
}
}
},
"Tokens": {
"type": "text",
"analyzer": "pageIndexAnalyzer",
"search_analyzer": "pageSearchAnalyzer"
},
"Type": {
"type": "long"
}
}
}
}
}
}

{
"autocomplete_tenant_1": {
"settings": {
"index": {
"number_of_shards": "5",
"provided_name": "autocomplete_tenant_1",
"creation_date": "1526462564455",
"analysis": {
"filter": {
"ngram": {
"type": "edgeNGram",
"min_gram": "2",
"max_gram": "15"
}
},
"analyzer": {
"keywordAnalyzer": {
"filter": [
"trim",
"lowercase",
"asciifolding"
],
"type": "custom",
"tokenizer": "keyword"
},
"pageSearchAnalyzer": {
"filter": [
"trim",
"lowercase",
"asciifolding"
],
"type": "custom",
"tokenizer": "standard"
},
"pageIndexAnalyzer": {
"filter": [
"trim",
"lowercase",
"asciifolding",
"ngram"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_replicas": "1",
"uuid": "l2AXoFNGRqafm42OSWWTAg",
"version": {
"created": "6020399"
}
}
}
}
}```


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.