Happening this week! Hear how Amplitude built a self-serve marketing engine to drive growth 🚀
Experimental feature

Studio search config

Omnisearch allows content search, can hide specific documents, and allows custom field weighting.

The global studio search panel (omnisearch) lets you search your content lake for any document that matches your term, or narrow down by filtering your query by schema types.

Hide documents from omnisearch

There may be instances where you don’t want specific documents from appearing in omnisearch.

To hide search results for a particular document type and remove it as a selectable filter:

{
  type: 'document',
  name: 'author',
  fields: [
    {name: 'name', type: 'string'},
    // ...
  ],
	// Hide all results for authors (and the author document type filter) in omnisearch
	__experimental_omnisearch_visibility: false,
  // ...
}

Some example use cases:

  • You have workflow-related documents that you don’t wish to expose editors to.
  • You want to hide documents that are less frequently used by editors.
  • You’re an author of a Sanity plugin that registers its own document schema and would prefer it doesn't appear in user's studios.

Protip

This only affects visibility within the global studio search (‘omnisearch’). Visibility in both reference and cross dataset reference input fields is unaffected.

Define custom weighting on fields

You can define specific weights on searchable fields for document types.

Search weights are configurable via options.search.weight. Here's an example:

{
  type: 'document',
  name: 'author',
  fields: [
    {
      name: 'name',
      type: 'string',
      options: {
        search: { weight: 10 },
        // ...
      }
    },
    {
      name: 'description',
      type: 'array',
      of: [{type: 'block'}],
      options: {
        search: { weight: 10 },
        // ...
      }
    }
    // ...
  ],
  // ...
}

A few things to note:

  • Supported fields for search configuration: Only string fields and portable text arrays are eligible for the new search configuration. These are the only fields that we currently index and thus are the only ones searchable. Searching within other field types or fields nested deeply in portable text arrays are currently not supported.
  • Global weight multiplier: Search weights act as global multipliers across all document types. For instance, if the name field in the customer type has a weight of 2, and in the author type has a weight of 4, then author documents will rank higher than customer documents for identical name matches in search results.
  • Default search configuration:
    • The field designated as the title in the preview config automatically receives a search weight of 10, while the subtitle field gets a weight of 5.
    • Fields marked as hidden: true in the preview config are assigned a weight of 0, effectively excluding them from search results.
    • Any user-specified weight overrides default settings, ensuring custom search relevance can be achieved as needed.

Was this article helpful?