Enabling Solr-SpellCheck Component

Please note :

These configurations are available on "sample_techproducts_configs" config sets, shipped with solr 5.x. In case of confusion, refer to the schema.xml and solrconfig.xml, placed there.

 

schema.xml configuration

1. Navigate to the respective collection's schema file.

2. Confirm if you have the below configs in place :
 
  2.1) Field defined as 'text'

<field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/> 

  2.2)  This field should have data copied from fields such as 'title', 'description', 'keywords', 'author' fields, and so on; on which you want to perform a spell check. Please add other fields —in the similar fashion— on which you'd want to do a spell check. 

 <copyField source="title" dest="text"/>
 <copyField source="author" dest="text"/>
 <copyField source="description" dest="text"/>
 <copyField source="keywords" dest="text"/>
 <copyField source="content" dest="text"/>

Other notes fyi : Default solr config have 'text' as field and 'text_general' as fieldType. And, 'text' is catchall field, containing all other searchable text fields, implemented  via copyField further on in this schema. 

 

solrconfig.xml configuration

1. Navigate to the respective collection's solrconfig.xml file
 
2. Confirm if you have the below configs in place :
 
2.1 A search component definition, as shown in below gist link

https://gist.github.com/rajanim/5e038fd6d996d0bba5c3#file-solr_spellcheck_component_definition

2.2 In order to retrieve the spell suggestions on the default "/select" request handler, add spellcheck component and itd default params to the handler—as it is shown in the below link

https://gist.github.com/rajanim/5e038fd6d996d0bba5c3#file-select_requesthandler_with_spellcheck


3. Reload collection with collection api[1] or restart solr and re index.  
 

Testing the setup

Index, Search and Retrieve Spell Suggestions

4.  For testing, index a document -
 {"id":"spell_1","name":"wireless phones provision"}
 
The value in the "name" field will be copied to "text" field— with copy feature as shown in schema config.

5. Now, search with the below query and you should be able to retrieve some suggestions as shown in the screen shot attached here to the article.

5.1 Search for 'wirless', it returns right suggestion. (attached in screenshot)
query. http://localhost:8983/solr/<collection_name>/select?q=wirles&wt=json&indent=true&


Note — I have attached the default schema.xml and solrconfig.xml that has these configs on it. Please refer to them, incase if you'd have confusion on where exactly to add the above configs in respective files.


 
[1]https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api2
 
 
 
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk