CodexBloom - Programming Q&A Platform

implementing Custom Analyzers in Elasticsearch 7.10 Not Applying as Expected

👀 Views: 0 💬 Answers: 1 📅 Created: 2025-06-13
elasticsearch analyzer text-search json

After trying multiple solutions online, I still can't figure this out. I'm trying to implement a custom analyzer in Elasticsearch 7.10 for my text fields to better handle specific tokenization and filtering needs. However, when I index documents, it seems that the custom analyzer is not being applied as I expected. I have defined my custom analyzer and the index settings as follows: ```json PUT /my_index { "settings": { "analysis": { "analyzer": { "my_custom_analyzer": { "type": "custom", "tokenizer": "whitespace", "filter": ["lowercase", "stop"] } } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_custom_analyzer" } } } } ``` After creating the index, I indexed a document like this: ```json POST /my_index/_doc/1 { "content": "Hello World! This is a test." } ``` When I perform a search query on this index: ```json GET /my_index/_search { "query": { "match": { "content": "hello" } } } ``` I am getting zero hits, but when I try the same query with a standard analyzer, I get the expected results. I’ve also verified that the custom analyzer is set correctly by checking the index settings. What might I be missing here? Is there something specific to the custom analyzer configurations that I should be aware of? I’ve already tried deleting and recreating the index, but the scenario continues. Any insights would be greatly appreciated! For context: I'm using Json on Ubuntu. What's the best practice here? The project is a REST API built with Json. Hoping someone can shed some light on this. This issue appeared after updating to Json 3.9. Thanks, I really appreciate it!