MGNLPER-19 - Getting issue details... STATUS
Periscope currently has various SearchResultSuppliers however all of them are bound to JCR. One should be able to define a SearchResultSupplier which brings results outside of Magnolia e.g. our documentation can be searchable within Periscope.
The usual way of doing this is to fetch/search this information via REST, hence we should be able to create generic REST based SearchResultSupplier for Periscope.
Providing capabilities as such is not very straightforward due to the fact that JSON response from REST based service will not be in the same format and/or same keys.
Proposed Solution (Periscope specific)
In the scope of Periscope, we only need to display results to the user and in order to do that we need a title and an URL that we will navigate to when user selects that particular result.
That means user only need to specify a title and navigation url via some kind of configuration and we will simply try to fetch that information in the SearchResultSupplier.
With JsonPath, one can easily point to particular values in any JSON result. That being said configuration as such is sufficient to configure a RestSearchResultSupplier.
This is an example of JSON response we get when we query confluence, it's clear that we need to combine 'title's and 'webui's to generate results.
With that in mind, one has to define titleJsonPath and navigationURLJsonPath according to the JSON result above.
This is how one defines where the specific values will be found, in this example we have '$..title' which translates into all title values which are two levels under the root and same as the '$..webui'.
One has to specific a 'baseURL' and an additional 'URL', those are needed to make the REST request from backend as well as appending the found 'navigationURL' from the JSON result.
Upon search request we append baseURL with URL and do the REST request and the response is parsed with JsonPath library and obtained 'title' and 'navigationURL' is utilised to generate results.
That being said, baseURL is appended with the parsed 'navigationURL' which is utilised to redirect the user when a particular response has been selected.
Getting results in the backend is very straightforward too: