Prashant Patil
Prashant Patil

Reputation: 2573

Apache Solr search query when user made a TYPO in text

I have added the data to solr.

Name field values are: "batman","bat man","bat-man"

so if a user searched for "btman" the result should show all the above values in search.

I found the query like: localhost:8983/solr/test/select?q=Name%3Abtman~2

but it won't work in all cases.

I need suggession for the Solr query which fetch the result with typos and recomendations.

Upvotes: 2

Views: 920

Answers (2)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8668

Solr comes with SpellCheck Compponent. The SpellCheck component is designed to provide inline query suggestions based on other, similar, terms. The basis for these suggestions can be terms in a field in Solr, externally created text files, or fields in other Lucene indexes.

In your case the spellcheck component will help you to achieve the same.

Please refer the solr documentation for configuring the spellcheck component.

Solr SpellCheck Compenent

If you query to the below url :

http://localhost:8986/solr/upgrade1/spell?q=retil&spellcheck.build=true&spellcheck=on&wt=xml

The result page :

enter image description here

Upvotes: 1

Amit
Amit

Reputation: 1121

IMO, you should use Synonym filter in Solr.

You basically need to create a Synonym file and pass it as an input where you think such spelling mistakes would occur.

Upvotes: 1

Related Questions