Unlock seamless workflows and faster delivery with our latest releases – get the details
Experimental feature

Studio search configuration

Global search for Sanity Studio allows content search, can hide specific documents, and allows custom field weighting.

The global search for Sanity Studio lets you search your Content Lake dataset for any document that matches your term, or narrow down by filtering your query by schema types. You can activate the global search from the 🔍 icon in the top toolbar, or with the ctrl/cmd + k hotkey.

Hide documents from global search

There may be instances where you want to keep specific documents from appearing in the search results. 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:

  • 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?