Book Image

ElasticSearch Blueprints

Book Image

ElasticSearch Blueprints

Overview of this book

Table of Contents (15 chapters)
Elasticsearch Blueprints
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Words with similar sounds


It would boost user experience if we could map words with similar sounds, such as forgot or forghot. We can use the phonetic analyzer for this.

The phonetic analyzer is a community-driven project and is capable of understanding words with similar sounds.

First, we need to install the phonetic analyzer. You can find the code base at https://github.com/elastic/elasticsearch-analysis-phonetic.

We can install the plugin using the following command:

bin/plugin install elasticsearch/elasticsearch-analysis-phonetic/2.4.2

Then, we need to create an analyzer out of it:

curl -X PUT "http://localhost:9200/my-index" -d '{
  "index": {
    "number_of_shards": 1,
    "number_of_replicas": 1
  },
  "analysis": {
    "filter": {
      "my_metaphone": {
        "type": "phonetic",
        "encoder": "metaphone",
        "replace": false
      }
    },
    "analyzer": {
      "metaphone": {
        "type": "custom",
  "tokenizer" : "standard",
        "filter": "my_metaphone"
      }
...