Using the built-in plugin in AWS - https://aws.amazon.com/about-aws/whats-new/2016/12/amazon-elasticsearch-service-now-supports-phonetic-analysis/.
Before indexing, I used this code to set up the phonetic analyzer.
PUT enpoint/courts_2
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"my_metaphone"
]
}
},
"filter": {
"my_metaphone": {
"type": "phonetic",
"encoder": "metaphone",
"replace": true
}
}
}
}
}
}
Note: I have not downloaded it specifically as AWS has it pre-built (Check above link).
Now,
I am using this code to make the query to the endpoint -
{
"query": {
"multi_match" : {
"query" : "Abhijith",
"fields" : ["content", "title^10"],
"analyzer": "my_analyzer"
}
},
"size": "1",
"_source": [ "title", "bench", "court" ],
"highlight": {
"fields" : {
"title" : {},
"content":{}
}
}
}
But I am getting zero results back. I am getting the below output:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
}
}
I can confirm that when not using the analyzer, I am getting back hits.
When I use this code, it returns normal output though.
GET courts_2/_analyze
{
"analyzer": "my_analyzer",
"text": "Abhijith"
}
Response
{
"tokens": [
{
"token": "ABHJ",
"start_offset": 0,
"end_offset": 8,
"type": "<ALPHANUM>",
"position": 0
}
]
}