Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic Search - implement "Did you Mean"

We are trying to use Elastic Search in a Rails app and would like any input/code example on the implementation of "did you mean" feature. Essentially, we want to provide the end user an option to search for an alternate query like in google.

like image 418
Sohan Avatar asked Aug 04 '11 04:08

Sohan


People also ask

Did you mean functionality in Elasticsearch?

Elasticsearch already has did-you-mean functionality which can correct the user's spelling after they have searched. Now, we are adding the completion suggester which can make suggestions while-you-type.

Why is Elasticsearch so popular?

Elasticsearch is built on top of the Apache Lucene search library, which makes it fast and scalable. Elasticsearch is a powerful search engine that is built on top of the Apache Lucene search library. Elasticsearch makes it fast and scalable, meaning that it can handle large amounts of data quickly and efficiently.

When should I use Elasticsearch?

You want Elasticsearch when you're doing a lot of text search, where traditional RDBMS databases are not performing really well (poor configuration, acts as a black-box, poor performance). Elasticsearch is highly customizable, extendable through plugins. You can build robust search without much knowledge quite fast.


2 Answers

As of version 0.90.0.Beta1, ElasticSearch has a "term suggest" feature included, which is what you are looking for:

http://www.elasticsearch.org/guide/reference/api/search/term-suggest/

E.g. get from this query: "devloping distibutd saerch engies" this result: "developing distributed search engines"

like image 188
Simon Steinberger Avatar answered Sep 23 '22 12:09

Simon Steinberger


Elasticsearch doesn't have it yet, it is opened as issue here basically it is waiting for the next Lucene release.

I achieved a similar "did you mean" behaviour using the phonetic analyzers, which worked for my use case, location names, that is not gonna work for all use cases....

a example mapping:- https://gist.github.com/1171014

so you can query using the REST api like this (mispelled london):-

{
  "query": {
    "field": {
      "nameSounds": "lundon"
    }
  }
}
like image 24
Ian Avatar answered Sep 24 '22 12:09

Ian