CodexBloom - Programming Q&A Platform

Elasticsearch 8.5 Not Applying Custom Analyzer for Multi-Field Query Across Indices

๐Ÿ‘€ Views: 0 ๐Ÿ’ฌ Answers: 1 ๐Ÿ“… Created: 2025-06-14
elasticsearch analyzer multi-field query json

I'm writing unit tests and I'm having a hard time understanding I'm experiencing an scenario with Elasticsearch 8.5 where a custom analyzer defined on an index is not being applied when I perform a multi-field query across different indices..... I set up my indices with a custom analyzer that should tokenize on both whitespace and punctuation, but when I try to search using this analyzer, I receive mismatched results that donโ€™t respect the analyzer settings. Hereโ€™s how I defined my custom analyzer in the index settings: ```json { "settings": { "analysis": { "analyzer": { "my_custom_analyzer": { "type": "custom", "tokenizer": "standard", "filter": ["lowercase", "trim"] } } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_custom_analyzer", "fields": { "keyword": { "type": "keyword" } } } } } } ``` I indexed some documents using this configuration, and they seem to be correctly analyzed according to the custom settings. However, when I perform a multi-field query like the following: ```json { "query": { "multi_match": { "query": "text to search", "fields": ["content", "content.keyword"] } } } ``` I get results that seem to ignore the lowercase transformation. Specifically, searching for 'Text' returns unexpected matches, including documents that should not match based on the analyzer settings. I have verified the mappings and reindexed the data, but the question continues. Could it be that the multi-field query isnโ€™t respecting the custom analyzer for the text fields? Or is there another configuration I should check? Any advice would be greatly appreciated. My development environment is Windows. Has anyone else encountered this? For context: I'm using Json on macOS. This is part of a larger REST API I'm building. Could someone point me to the right documentation? This is my first time working with Json 3.11. Could someone point me to the right documentation? This is my first time working with Json 3.10.