-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
NEST/Elasticsearch.Net version:
7.9.0
Elasticsearch version:
7.6.1 (Docker)
Description of the problem including expected versus actual behavior:
Hi, I basically need to query on text fields using a case insensitive Prefix to get all records having their productSearchName field "starting with" something.
Example of data :
productSearchName= "12 tons of ..."
productSearchName= "12 Tons of ..."
productSearchName= "12 TONS of ..."
I would like to get all these three records using a Prefix query, like
GET catalog/_search
{
"_source": ["id", "productSearchName"],
"query":
{
"prefix": {
"productSearchName.Keyword": {
"value": "12 tons"
}
}
}
}
When defining a Normalizer (as I understood it's the correct approach, is it ?) and telling my field should use it, the field is not mapped as expected, it's a "basic" text fields on Keyword
"productSearchName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
My query against the field indeed does not retrieve all records as expected.
I indeed reindexed my whole documents on a dedicated index with the provided mapping.
Steps to reproduce:
Here is my IndexDescriptor
c => c
.Settings(s => s.Analysis(a => a
.Normalizers(n => n.Custom("case_insensitive", c => c.Filters("lowercase")))
))
.Map<Catalog>(m => m
.AutoMap()
.Properties(p => p
.Keyword(st => st
.Name(n => n.ProductSearchName)
.Normalizer("case_insensitive")
)))
Expected behavior
I expect the ProductSearchName field to use the provided normalizer, and then being able to query in a case insensitive way using Prefix instruction, and then get all my 3 example records.