Implement full-text fuzzy prefix search in Elastic search


(Jason Bai) #1

I understand that Elasticsearch tries to avoid using Fuzzy search with prefix matching, and this is also why it doesn't natively support such feature due to its complexity. However, we have a directory search system that solely relies on elasticsearch as a blackbox search engine, and we need the following logic:

E.g. Say the terms are "Michael Pierce Chem". We want to support full text search on the first two terms (with match query) and we also want to do fuzzy on the last term first and then do a prefix match, as if "Chem" matches "chemistry" and "chen".

Please give me some advice on the implementation and design suggestions. Current stack is a NodeJS web app with Elasticsearch.


(Pranav) #2

Don't quote me on this but you can use Edge N-gram analyzers to provide auto complete and use fuzziness in your query. As for as i know prefix phrase query doesn't support fuzziness. When you employ Edge N-Gram you can use simple match query or Query String query with fuzziness


(Jason Bai) #3

Thank you! Let me try if combining Edge N-Gram with Query String query can work as desired.