0

I want to add a custom phonetic analyzer, also I don't want to analyze my given string. Suppose, I have two string,

KAMRUL ISLAM

KAMRAL ISLAM

I don't want to get any result with a query string KAMRUL but want both two as a result with query string KAMRUL ISLAM.

For this, I have take a custom phonetic analyzer with a keyword tokenizer.

Index Settings :

PUT /my_index
{
  "settings": {
    "analysis": {
      "filter": {
        "dbl_metaphone": { 
            "tokenizer": "keyword",
          "type":    "phonetic",
          "encoder": "double_metaphone"
        }
      },
      "analyzer": {
        "dbl_metaphone": {
          "tokenizer": "keyword",
          "filter":    "dbl_metaphone" 
        }
      }
    }
  }
} 

Type Mappings:

PUT /my_index/_mapping/my_type
{
  "properties": {
    "name": {
        "type":     "string",
        "analyzer": "dbl_metaphone"
      }
    }
}

I have inserted data with :

PUT /my_index/my_type/5
{
  "name": "KAMRUL ISLAM"
}

And My query String:

GET /my_index/my_type/_search
{
  "query": {
    "match": {
      "name": {
        "query": "KAMRAL"
      }
    }
  }
}

Unfortunately I am given both two string. I am using ES-1.7.1. Is there any way to solve this ?

Additionally, While I have run

curl -XGET 'localhost:9200/my_index/_analyze?analyzer=dbl_metaphone' -d 'KAMRUL ISLAM'

I got the result:

{
  "tokens": [
    {
      "token": "KMRL",
      "start_offset": 0,
      "end_offset": 12,
      "type": "word",
      "position": 1
    }
  ]
}

And While running :

curl -XGET 'localhost:9200/my_index/_analyze?analyzer=dbl_metaphone' -d 'KAMRAL'

I have got:

{
  "tokens": [
    {
      "token": "KMRL",
      "start_offset": 0,
      "end_offset": 6,
      "type": "word",
      "position": 1
    }
  ]
}
Community
  • 1
  • 1
sunkuet02
  • 2,376
  • 1
  • 26
  • 33
  • Can you update your question with the result you get when running `curl -XGET 'localhost:9200/_analyze?analyzer=dbl_metaphone' -d 'KAMRUL ISLAM'` and `curl -XGET 'localhost:9200/_analyze?analyzer=dbl_metaphone' -d 'KAMRAL'` ? – Val Jun 20 '17 at 09:01
  • @Val, I have updated my question, please review this. – sunkuet02 Jun 20 '17 at 09:12
  • 1
    Then you have your answer, since both produce the same token, both docs come back. – Val Jun 20 '17 at 09:15
  • @Val, is there any way to solve my issue? you can change my settings and mappings. – sunkuet02 Jun 20 '17 at 09:23

0 Answers0