close

Filter

loading table of contents...

Headless Server Developer Manual / Version 2101

Table Of Contents

4.9 Search

To use Headless Server search, an existing Solr with an index created by a CAE Feeder needs to be provided.

Search is handled with the searchServiceAdapter adapter. The following functionality is supported:

  • Full text search
  • Paging
  • Limit
  • Filter by content type, optionally including their sub types
  • Predefined sort fields with order
  • Limitation to a site
  • Valid from and valid to conditions are applied to search filters automatically

The following GraphQL query is a simple example for fetching a search result.

{
  content {
    search(query:"Perfect") {
      numFound
      result {
        name
      }
    }
  }
}
  

Several parameters can be passed to the SearchServiceAdapter to customize the search:

  • query: The search query.
  • offset: The offset.
  • limit: The limit of search result.
  • docTypes: Content types to restrict the search result.

    Misspelled content types are ignored. When passing an abstract content type, the subtypes are retrieved, if the parameter includeSubTypes = true. The search result does not contain abstract document types.

  • sortFields: List of sort field with order, separated by '_', in upper case, for example, ID_ASC.

    The set of available sort fields is limited to the enum SortFieldWithOrder defined in the content schema: ID, DOCUMENTTYPE, TITLE, TEASER_TITLE, MODIFICATION_DATE, CREATION_DATE, EXTERNALLY_DISPLAYED_DATE

    The fields of the enum above however can be extended by more fields. Currently the SearchServiceAdapter supports these sort fields: ID, DOCUMENTTYPE, NAVIGATION_PATHS, NOT_SEARCHABLE, SUBJECT_TAXONOMY, LOCATION_TAXONOMY, TITLE, TEASER_TITLE, TEASER_TEXT, KEYWORDS, MODIFICATION_DATE, CREATION_DATE, TEXTBODY, SEGMENT, COMMERCE_ITEMS, CONTEXTS, AUTHORS, HTML_DESCRIPTION, VALID_FROM, VALID_TO, EXTERNALLY_DISPLAYED_DATE

    Possible order field values: ASC, DESC

  • siteId: The siteId can be passed as parameter to restrict search per site.
  • includeSubTypes: A Boolean flag, indicating to include the sub types of the given doc types in the search. Defaults to 'false'.

The query parameter supports the following syntax:

  • The + and - characters are treated as "mandatory" and "prohibited" modifiers for terms.
  • Quoted expressions, like "Foo Bar" are treated as a phrase
  • An odd number of quote characters is evaluated as if there were no quote characters at all.
  • The wildcard character '*' supports the search for partial terms like 'frag*', which would find, for example, the terms 'fragment' and 'fragile' as well. When used exclusively as a search query, the search is executed with all other search parameters but without an explicit search expression.

By default, the SearchServiceAdapter uses the caeSolrQueryBuilder Spring bean, which in turn invokes searches on Solr on the cmdismax endpoint. For details, see Section 3.8.1, “Details of Language Processing Steps” in Search Manual.

The used endpoint can be customized in CaasConfig. See section customization at the end of this chapter for details.

The following GraphQL query is a more complex example for fetching a search result.

{
  content {
    search(query: "Perfect", offset: 3, limit: 5, docTypes: ["CMArticle", "CMPicture"], sortFields: [CREATION_DATE_ASC, MODIFICATION_DATE_ASC], siteId: "abffe57734feeee", includeSubTypes: true) {
      numFound
      result {
        name
        type
      }
    }
  }
}

  

If docTypes or limit is not passed as parameter, the following search configuration is taken into account, which is read from CMS content using settings. See general search configuration for details in Blueprint Developer Manual .

  • searchDoctypeSelect, search.doctypeselect: document types to restrict the search result
  • searchResultHitsPerPage, search.result.hitsPerPage: limit of the search result

Valid from and valid to conditions are applied to search filters automatically.

Configuring Search

The connection to Solr is defined with solr.url

The search index is specified with property caas.solr.collection

Caching is only performed in live mode and can be configured with caas.search.cache.seconds

Customization

If search should be performed with a different index, you have to implement SolrQueryBuilder in your own class. The searchHandler can be passed as a constructor argument.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.