Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Solr schema problem for autocomplete

I have a very simple SQL table that I want to import into Solr but because of the features I want for search I can't determine the best schema.

The user will start typing into an input box and after 3 characters it will send the request to the server and pull out the most relevant results returning the top 15 matching id and name.

Table ex)

id | name
----------------
1 | boating magazines
2 | boats weekly
3 | boaters collection
4 | shipping lane
5 | ships today

Search and expected return ex)

boa | [1, boating magazines], [2, boaters weekly], [3, boaters collection] 
boat | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]
shi | [4, shipping lane], [5, ships today]
ship | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]
boating | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]

(obviously those would be returned as xml)

Any info on how I would achieve this would be appreciated. Thanks.

like image 573
user103219 Avatar asked Aug 27 '26 23:08

user103219


1 Answers

You can implement this using either facet.prefix, TermsComponent or NGrams.

One of those articles also shows how to bind it using jQuery or you could use ajax-solr.

By the way, a specific autosuggest component is to be included in the next release of Solr.

like image 97
Mauricio Scheffer Avatar answered Aug 31 '26 05:08

Mauricio Scheffer