laravelelasticsearchelasticsearch-phonetic

Laravel elastic search implement soundex


I'm facing an issue on the elastic search that it's not able to search if someone types wrong spelling. I have done some R & D about Soundex. Now I'm facing an issue to implement Soundex on elastic search. Please help me to do that, I've already installed Phonetic Anaalysis plugin on elastic search but how to configure the plugin with elastic search that will work with the search results.

'title' => [
                    'type' => 'text',
                    'analyzer' => $language . '_analyzer',
                    'index' => true,
                    'norms' => false,
                    'term_vector' => 'with_positions_offsets',
                    'fields' => [
                        'raw' => [
                            'type' => 'keyword',
                            'normalizer' => 'lowercase_normalizer',
                            'index' => true,
                            'norms' => false,
                        ],
                    ],
                ],

Solution

  • You need to create a custom analyzer using phonetic token filter and the apply this custom analyzer to your text field.

    Alternatively, if you want to search with mistypes you can use fuzzy matches.