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
Blog-only search
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:
- Set
Paths where this lens should be usedto/blog*. - Keep
Search inputsenabled. - Disable
Search overlayif the header search must continue to search the full site. - Disable documents if they must not appear in blog search.
- 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.
Multilingual search
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:
- Set
Paths where this lens should be usedto/de*. - Enable the search interfaces used on German pages.
- 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.