pandey
pandey

Reputation: 15

Custom stopword analyzer is not woring properly

I have created an index with a custom analyzer for stop words. I want that elastic-search to ignore these words at the time of searching. Then I added one document data in elasticsearch mapping. but when I am querying in kibana for "the" keyword with the query. It should not show any successful match, because in my_analzer I have put "the" in my_stop_word section. But it is showing the match. I have studied that if you mention one analyzer at the time of indexing in the mapping field. then it takes that analyzer by default at the time of the query. please help!

PUT /pandey
{ 
  "settings":  
  { 
    "analysis":  
    { 
      "analyzer":  
      { 
        "my_analyzer":  
        { 
          "tokenizer": "standard", 
          "filter": [ 
            "my_stemmer", 
            "english_stop", 
            "my_stop_word", 
            "lowercase" 
          ] 
        } 
      }, 
      "filter": { 
        "my_stemmer": { 
          "type": "stemmer", 
          "name": "english" 
        }, 
        "english_stop":{ 
          "type": "stop", 
          "stopwords": "_english_" 
        }, 
        "my_stop_word": { 
          "type": "stop", 
          "stopwords": ["robot", "love", "affection", "play", "the"] 
        } 
      }
    } 
  },
  "mappings": {
    "properties": {
      "dialog": {
        "type": "text",
        "analyzer": "my_analyzer"
      }
    }
  }
}


 PUT pandey/_doc/1
 {
    "dailog" : "the boy is a robot. he is in love. i play cricket"
 }

 GET pandey/_search
    {
      "query": {
        "match": {
          "dailog": "the"
        }
      }
    }

Upvotes: 0

Views: 259

Answers (1)

Vinod
Vinod

Reputation: 1953

A small spelling mistake can lead to this.

You defined mapping for dialog but added document with field name dailog. the dynamic field mappings behavior of elastic will index it without error. we can disable it though.

So the query, "dailog": "the" will get the result using default analyzer.

Upvotes: 1

Related Questions