Advanced guides

Introduction to search lenses

What is a search lens?

A search lens controls search results for a specific part of your site or a specific search interface.

Use lenses when parts of the site need different search behaviour. For example, a blog search input can return only blog posts.

Each lens controls:

  • where the lens applies
  • which content the lens can return

Examples

In this example, the blog is under /blog. The header link to /search searches the full site. A search input on the blog searches only blog content.

Create a lens on the Search lenses page. Then set these options:

  1. Set Paths where this lens should be used to /blog*.
  2. Keep Search inputs enabled.
  3. Disable Search overlay if the header search must continue to search the full site.
  4. Disable documents if they must not appear in blog search.
  5. In Pages to include or exclude, enter /* to exclude all pages. Then enter !/blog* to include the blog.

Save the lens. The header search still searches the full site. The blog search input returns only blog content.

Use one lens for each language path. For example:

  • acme.org and acme.org/en for English
  • acme.org/no for Norwegian
  • acme.org/de for German

Use the Default lens for English. In Pages to include or exclude, exclude the other language paths:

# Exclude Norwegian pages
/no*

# Exclude German pages
/de*

Create a German lens:

  1. Set Paths where this lens should be used to /de*.
  2. Enable the search interfaces used on German pages.
  3. In Pages to include or exclude, enter:
/*
!/de*

Create the Norwegian lens in the same way. Use /no* for the path and these exclusion rules:

/*
!/no*

Save the lenses. Use the lens tester on the Search lenses page to confirm which lens applies to each path.

Help

Contact support if you need help with a lens.