Apache Solr search query when user made a TYPO in text

753 Views Asked by At

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.

2

There are 2 best solutions below

0
Amit On

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.

1
Abhijit Bashetti On

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