Single Search Page Integration And The Panl Response Object

The Panl server also binds to a URL which will return the LPSE configuration as a JSON response to be used to generate a single search page - i.e. one that contains all of the facets that can be placed on a single page for users to select all values.

Tip: The single search page is useful where the number of facets are small and, irrespective of the combinations of facets, will always return search results.  For some single search pages, a combination of selected facets may return no results, which should be avoided.  Of course, a separate CaFUP can be configured to only provide a small subset of facets and then used for the single search page.


How you choose to implement the Single Page Search interface is up to you, as a starting point you can view the in-built implementation for the latest version on github:

The HTML index page:

https://github.com/synapticloop/panl/blob/main/src/main/resources/webapp/single-page-search/index.html 

The JavaScript implementation

https://github.com/synapticloop/panl/blob/main/src/main/resources/webapp/static/panl-single-page-search.js

The key information that is required, is the LPSE order, and the LPSE facets that exist.

URL Bindings

The Panl JSON responses are bound to the Panl URL path in the form of
http://localhost:8181/panl-configuration/<panl_collection>/

For example, the mechanical-pencils Panl collection is bound to

http://localhost:8181/panl-configuration/mechanical-pencils/

Which will return the JSON response detailed below.

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.

An example 404 response (in non-verbose mode):

01

02

03

04

05

{

  "error":true,

  "status":404,

  "message":"Not found"

}

An example 500 response (in non-verbose mode):

01

02

03

04

05

{

  "error":true,

  "status":500,

  "message":"Internal server error"

}


Success Responses

Unlike the Panl Results Viewer and Explainer, this is a separate response with no Solr JSON response included.

The JSON response object has the following form:

01

02

03

04

05

06

07

{

  "error": "false",

  "panl": {

    "lpse_lookup": { ... },

    "lpse_order": [ ... ]

          }

}


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 are two keys, lpse_lookup and lpse_order which are detailed below.

The "lpse_lookup" JSON Object

This JSON object is a simple lookup keyed on the LPSE code, with the value being the index of the LPSE path.  All valid facets are contained within the lookup including LPSE parameters pagination, sorting, number of results per page and query operand.  

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

19

20

21

{

  "9": 12,

  "b": 1,

  "C": 6,

  "D": 8,

  "G": 5,

  "h": 9,

  "I": 10,

  "L": 7,

  "m": 3,

  "N": 2,

  "n": 16,

  "o": 17,

  "p": 15,

  "q": 18,

  "s": 14,

  "W": 4,

  "w": 13,

  "z": 0,

  "Z": 11

}


This lookup is used to build the correct ordering for the LPSE URL path, being able to use the facet LPSE code as a lookup for the index of the URL.

Note that pagination, number of results, query operand and sorting are not implemented in the in-built web app.

The "lpse_order" JSON Array

This array contains the returned Solr facets in the LPSE order.  The array element will be null if the facet is not available.  The Objects are identical to the panl.available facet object, containing identical keys and values to an empty search.  To implement the interface for any of these facets, use the same logic as detailed in the Search Integration And The Panl Response Object section.

Generating the LPSE URL path

Each of the facets is rendered in order of the LPSE path.  On change of any of the values, the panl_code can be used as the lookup key on the panl.lpse_order object.  This will return the order in the LPSE URL path that it should be placed.

~ ~ ~ * ~ ~ ~