I am using OpenSearch version 7.10.2 and encountering an issue with the match_phrase_prefix
query on certain asset numbers. My asset_number
field is analyzed using a lowercase analyzer. Here is the detailed setup:
Index Settings:
{
"settings": {
"analysis": {
"normalizer": {
"lowercase_normalizer": {
"type": "custom",
"filter": ["lowercase"]
}
}
}
},
"mappings": {
"_routing": {
"required": true
},
"properties": {
"asset_number": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
}
}
}
}
}
}
Problem Description
I have an index with asset_number
values and am trying to run a match_phrase_prefix
query to fetch assets starting with specific prefixes. The query works for some prefixes but not for others. Here are the results
- Working: PB1234, PE1234, PG1234, PI1234, PJ1234, PK1234, PL1234, PM1234, PN1234, AH1234, BH1234
- Not working: PC1234, PD1234, PF1234, PH1234, AC1234, BC1234, AD1234, BD1234, CA1234, CB1234, CC1234, CD1234, CE1234, DA1234, DB1234, DC1234, FA1234
The query is supposed to match asset numbers that start with specific prefixes like “PC”, “PD”, etc., but it fails for many of them.
Query Used
{
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"asset_number": "pc"
}
}
]
}
}
}
Any suggestions on what might be causing the query to fail for specific prefixes or how to fix this issue?
Additional Information:
- OpenSearch version: 7.10.2
- Lucene version: 9.4.2
- Query works for some prefixes but not others even though they are in the same index.