Using your search index as a content source

Using the index to populate content

Use you 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.

You should always use a different DXP search results page for any system generated searches. If you use the same results page as you do for the standard search results your analytics data will be polluted with the system generated queries and often contain weird looking queries that utilize the search query language.

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, yoo can use the REST integration method in a manner similar to:

  1. In the DXP search, create a separate results page for this.

  2. 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.

  3. Create a suitable Freemarker template that returns the results in the desired format.

  4. 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.

  5. 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.

recommendation web service

See: DXP search documentation - recommendations for information on setting up the recommendations service.