Elasticsearch analyzer working with _search


(krishna singh) #1

I defined a standard analyzer & mapping that I was surprised not built-in.

PUT /_template/mytemplate
{
"template": "kindex*",
"settings": {
"analysis": {
"analyzer": {
"kanalyzer": {
"type": "standard",
"stopwords": "the"
}}
}},
"mappings" : {
"kindex" : {
"properties" : {
"message" : { "type" : "string","analyzer" : "kanalyzer"}
}
}
}
}

Then i put different values in my kindex/ktype

PUT /kindex/ktype/3
{
"message":"this is abc the work "
}

PUT /kindex/ktype/2
{
"message":"this is xyz the work "
}

when i am searching it with
localhost:9200/kindex/ktype/_search
It give output as it is not by removing "the" word as written in my analyzer.

It looks like elasticsearch performs the search with the default analyzer, which doesn't make sense. Shouldn't it perform the search with each field's own default analyzer?
please help me out.


(Luca Cavanna) #2

Can you try and see what the output of the analyze api is when you use your custom analyzer? Don't forget to specify the index name so that your custom analyzer can be found.


(system) #3