Auto-Suggestion (Auto-Complete) Box

For your application, you may have auto-suggest (or call auto-complete) feature in searching field, such as https://jqueryui.com/autocomplete/#remote .

 

When user enters two or more than two characters, it will trigger auto-complete action, and remote lookup external web API, which returning list of data in JSON format.

So, for example, your application can query SOLR using JQuery or other JS, it can return JSON data so that JQuery can show the data on the webpage.

Please find the below SOLR query examples for auto-suggestion:

Requested URL

http://localhost:8983/solr/films/select?q=name:*king*&fl=name&wt=json&indent=true&omitHeader=true

Parameters Values Details
q name:*king* Auto-suggesting “name” field
fl name Return “name” field only
omitHeader true By default, it is false.

When true, returning JSON will omit the header, you can try the above request with and without omitHeader, and see what is the different.

 

Requested URL

http://localhost:8983/solr/films/terms?terms.fl=name&terms.prefix=ki&wt=json&indent=true&omitHeader=true

Details

 Besides using normal search like the first example, you can also use “terms” to lookup the keyword like this example. Please note that it is calling to “terms” request handler instead of “select”.

Parameters Values Details
terms.fl name Return “name” field
terms.prefix ki Lookup terms prefix

 

Please rate this