GraphQL Search API

Contents

Endpoint

The API’s default location is:

http://localhost:8080/webapp/com.enonic.app.explorer/api/graphql

Production deployment

Use vhosts to deploy the API on a custom domain/URL.

com.enonic.xp.web.vhost.cfg
enabled = true

mapping.explorerApi.host = company.com
mapping.explorerApi.source = /search-api
mapping.explorerApi.target = /webapp/com.enonic.app.explorer/api/graphql

In the above example, the API will be available on company.com/search-api

Security

Access to the API requires that you create and submit a valid API key in the HTTP request header.

GraphQL browser

The API is self-documented, and can be accessed directly using the Query tester in Explorer Admin

To test the public endpoint directly, we recommend using a tool like a browser extension like the Altair GraphQL client.

Usage

Below you will find some sample queries

Advanced search for bananas using the minions interface
query MyQuery {
  interface(name: "minions") {
    querySynonyms(searchString: "bananas") {
      search(
        filters: {boolean: {must: {exists: {field: "title"}} }}
        count: 1
        highlight: {fields: [
          {field: "title"}
          {field: "text"}
          {field: "_allText"}
        ]}
        aggregations: [
          {name: "collections", terms: {field: "_collection"}},
          {name: "documentTypes", terms: {field: "_documentType"}}
        ]) {
        count
        total
        aggregationsAsJson
        hits {
        _highlight
        _collection
        _documentType
      # _json
        _score
        }
      } # search
      languages
      synonyms {
        thesaurusName
        synonyms {
          locale
          synonym
        }
      } # synonyms
    }
  }
}

Contents

Contents