Search clients

Contents

Introduction

Explorers ability to create fully customised search interfaces is the icing on the cake. By default, Explorer does not expose any web APIs, but rather enable developers to access the interfaces through an internal JavaScript API.

Search apps

There are numerous ways of exposing your search data from Explorer, but they all start with the development of a custom XP application.

The application will use Explorers API, and then offers a solution to exposing the data. Here are the most common approaches:

Server pages

Search interface and results delivered as good old web pages.

RESTful API

Exposes your search interface through a RESTful API of your preferred format and style, to be consumed by any client. This may also be secured as required.

GraphQL API

Exposes your search interface through graphQL. Check out Enonic’s GraphQL library for more details. The API may be secured according to your requirements.

API and front-end

Finally, you may combine the above, and have your app deliver both the API and front-end clients through XP as desired.

Using the Explorer Client starter

Here’s a tutorial on how to use the Explorer Client starter

Using the search API

There are numerous ways to return a search result.

Perhaps you want to provide a JSON service to be used with a react frontend, or do a static HTML page by rendering server-side.

Common to all solutions is that you have to call the search api, and perhaps manipulate the result to your liking.

Below is an example of how to invoke the search API:

controller.es
import {search} from '/lib/explorer';

export function get({
	params
}) {
	const {
		facetCategories,
		pages,
		pagination,
		hits,
		removedStopWords,
		synonymsObj,
		total = 0
	} = search({
		clearCache,
		//count: 10,
		facets: {
			language: params.language,
			'information-type': params['information-type'],
			source: params.source
		},
		interface: interfaceName,
		locale,
		name,
		page,
		searchString
	});
}

Site integration

When integrating search in a site, it may be practical to enable editors to select which interface to use in the search.

A custom selector may be a practical solution to this.

Custom selector

Explorer’s API provides a service that can be used by a custom selector in any site application.

TODO: Confirm service is part of library

controller.xml
<input name="interface" type="CustomSelector">
	<label>Interface</label>
	<occurrences minimum="1" maximum="1"/>
	<config>
		<service>interfaceSelector</service>
	</config>
</input>

The service can currently only be accessed with any of these roles:

  • Content Manager Administrator (cms.admin)

  • Content Manager App (cms.cm.app)

  • Content Manager Expert (cms.expert)

  • Administrator (system.admin)

  • Administration Console Login (system.admin.login)


Contents

Contents