Lookahead Integration And The Panl Response Object
Lookahead (or type-ahead) is common on many sites, allowing a user to instantly see returned results as they type in the search box.
The number of documents that are returned by the Lookahead binding is set by the property solr.numrows.lookahead in the <panl_collecton_url>.panl.properties file which, by default is 5.
Where the 'More Facets' Panl URL binding will return facets, but no documents, the inverse is true of the 'Lookahead' Panl URL binding in that it will return no facets, but will return documents.
URL bindings
The Panl JSON responses are bound to the Panl URL path in the form of
http://localhost:8181/panl-lookahead/<panl_collection>/<fieldset>
For example, the mechanical-pencils Panl collection is bound to
http://localhost:8181/panl-lookahead/mechanical-pencils/*
It requires additional URL information and query parameters to work, the query parameter MUST be the same as the panl.form.query.respondto as set in the <panl_collecton_url>.panl.properties file and will return the defined fieldset. Consequently the URL that is generated should have the form of:
http://localhost:8181/panl-lookahead/mechanical-pencils/brandandname/?search=hexagonal
Which would perform a keyword search on hexagonal and would return 5 results as per the configuration of the solr.numrows.lookahead property.
|
Tip: You may wish to define a new CaFUP with a specific FieldSet that just returns the data required for the Lookahead functionality. |
Building the Request URL
To request more facet values for a specific LPSE code, the url would look like the following - the initial request:
http://localhost:8181/panl-results-viewer/mechanical-pencils-more/brandandname/Clutch/m/
Is searching for mechanical pencils which have a 'Clutch' mechanism. The limit for the facets for this CaFUP configuration is set to 10 - i.e. solr.facet.limit=4. The image below shows the returned facets with the See all... link appearing at the bottom of the facets.
|
Note: This above request URL is for the CaFUP binding in the sample/panl/mechanical-pencils/mechanical-pencils-more.panl.properties file which is not included in the default mechanical pencils panl.properties file and will have to be enabled. |
Image: The 'Lookahead' implementation on the in-built Panl Results Viewer
|
Note: In the Panl Results View Web App, the lookahead functionality is only triggered when greater than three (3) characters are entered and returns the fields from the JSON Response of brand and name. The in-built implementation functionality ONLY supports the mechanical pencils Solr collection. |
Error Responses
There will ALWAYS be an error key (with a boolean value of either true or false) on all responses which makes it easy to determine the best course of action. If there is an error (either 404, or 500), then the error key will be set to true, an integer status code keyed on status, and keyed on message, a human readable response.
Success Responses
Unlike the Panl Results Viewer and Explainer, this is a separate response with minimal Solr JSON response information included.
The JSON response object has the following form:
01 02 03 04 05 06 07 08 09 10 11 12 13 |
{ "response": { "docs": [ ... ] "numFound": 45, "start": 0, "maxScore": 0.17629748582839966, "numFoundExact": true }, "panl": { "timings": { ... } } } |
The Panl response only has two keys, namely a boolean valued key of error, and a JSON object keyed on panl to the root object.
|
Note: The error key will __ALWAYS__ be false for a successful return of the Panl Response object. |
Within the panl JSON Object key, there is only one key - facet which is detailed below.