Using your search index as a content source
Using the index to populate content
Use the search index as a data source that populates dynamic content areas on a page in a similar way to how you might pull in content from a database.
Always use a different DXP search results page for system generated searches. Using the standard search results page causes analytics data to be polluted with system generated queries. System generated queries often utilize the search query language and present as ‘weird looking’. |
You can use the same integration methods that are available when setting up a search results page (REST asset integration or JSON/XML integration). The difference here is that you are predefining what the query is, and the 'search results' template is formatted to look like site content.
For example, use the REST integration method to:
-
In the DXP search, create a separate results page for this.
-
Optionally disable logging (by adding
-log=off
to the query_processor_options in the results page configuration, unless usage analytics are of particular interest. Most of the time the analytics will not be useful because the searches are predefined. -
Create a suitable Freemarker template that returns the results in the desired format.
-
Use the same REST integration method to make the relevant query and format the results. Depending on the application the query might be completely 'static' (i.e. All the parameters, including the query are hardcoded in the request URL), or may have variable components that a user can set via controls within the web page. The URL called by the REST asset should be updated to appropriately reflect the desired query.
-
Configure appropriate caching for the REST asset.
All results JSON/CSV endpoint
There is an additional endpoint available that is often better suited when using the search index as a content source. The all-results endpoint can return search result data as JSON or CSV format.
Advantages of the all-results endpoint:
-
The full set of results can be streamed back to the caller in a much more compact data model.
-
For queries that need large numbers of results returned this method performs much better.
Limitation of the all-results endpoint:
-
You only have access to the result data - there’s no access to the search question element, or other parts of the standard data model outside the
response.resultPacket.results
element. This includes summary information (like result counts), and other features like faceted navigation - if you need any of this information you have to use the standard search JSON endpoint.
The parameters used for calling the all-results endpoint differ from the standard search JSON endpoint. The endpoint also ignores the query processor options that you have set within the results page configuration. |
Integration with this endpoint is similar to the Integrate with the search results JSON endpoint method for standard search results.
Recommendations
The DXP search includes a recommendation service that can be used to provide recommendations of similar pages (similar to the users who were interested in X were also interested in Y type pages often found on e-commerce websites).
The recommendations service is accessed via an API that returns a JSON packet.
See: DXP search documentation - recommendations for information on setting up the recommendations service.