Friday 20 November 2015

Elasticsearch: Disabling stop words

You can disable stop words by setting the field ‘stopwords’ to  “_none_”. Delete index “blog” if any.
POST /blog
{
 "settings": {
  "analysis": {
   "analyzer" :{
    "custom_english_analyzer" : {
     "type" : "english",
     "stopwords" : "_none_"
    }
   } 
  }
 }
}

POST /blog/_analyze?analyzer=custom_english_analyzer
{"Hari and PTR are friends"}

You will get following response.    
{
   "tokens": [
      {
         "token": "hari",
         "start_offset": 2,
         "end_offset": 6,
         "type": "<ALPHANUM>",
         "position": 1
      },
      {
         "token": "and",
         "start_offset": 7,
         "end_offset": 10,
         "type": "<ALPHANUM>",
         "position": 2
      },
      {
         "token": "ptr",
         "start_offset": 11,
         "end_offset": 14,
         "type": "<ALPHANUM>",
         "position": 3
      },
      {
         "token": "ar",
         "start_offset": 15,
         "end_offset": 18,
         "type": "<ALPHANUM>",
         "position": 4
      },
      {
         "token": "friend",
         "start_offset": 19,
         "end_offset": 26,
         "type": "<ALPHANUM>",
         "position": 5
      }
   ]
}



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment