London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Loading...

Support for full-text search in fields

This topic describes how to work with opt-in for content properties, when using the GraphQL API for the Optimizely querying service, to retrieve content in Optimizely solutions.

Note: This feature is not yet available, but will be released within shortly.

How it works

Properties on content types are opt-in for full-text search support. By default, all fields are filtered on only as an exact value. When fields need to have full-text search support, including tokenization and language stemming, the contains operator is used.

Enabling full-text search support for fields

Enabling full-text search support can be done from the CMS Admin view by selecting the Searchable property option as shown in the image. This option is available for each property on the content type. 

Opt-in for content properties

Note: When the Searchable property option has been changed, the Content type indexing job will start automatically, but you also need to manually run the Content indexing job.

The change is reflected in the GraphQL schema schema with the SearchableStringFilterInput type for fields where this option has been enabled. This adds the support for the contains operator.

Searching content for all searchable fields with _fulltext

The GraphQL querying service generates a special _fulltext field for each content type. This will match the searchable fields on all content. The separate values of the searchable fields are preserved, without any overlap between values.

When the Searchable property is enabled for a field, all its child elements will also be made searchable. The use of the _fulltext field is more efficient than quering for searchable fields separately. It is not possible to project the content of the _fulltext field.

Getting all searchable field values in content type is Content

The GraphQL querying service supports to get all searchable field values (includes its nested field values) in one field _fulltext with array string type. This only supports for content type is Content.

The query like this bellow:

{
  Content(locale: en) {
    Name
    _fulltext
  }
}

The result like this bellow:

"data": {
  "Content": [
    {
  	"Name": "Abraham Lincoln",
  	"_fulltext": [
  	  "Abraham Lincoln",
  	  "“With malice toward none; with charity for...",
  	  ...
  	]
    },
    {
  	"Name": "Vincent Van Gogh",
  	"_fulltext": [
  	  "<h3>Example</h3>",
  	  "Vincent Van Gogh",
  	  ...
  	]
    },
    ...
  ]
},

Related topics

Last updated: Jun 28, 2021