Limit results returned from query by URL path

Hi All, we have two different places I want to add Algolia to on our website. Our product documentation, and our Company Handbook. I need to be able to have two different search bars on our site, one that just returns Handbook-related content, and the other returning docs content.

On our site, the relevant content lives at /handbook/* and /docs/* respectively.

The site is built in Eleventy, hosted on Netlify.

I’ve thought of the following the options:

  1. Two Crawlers: Have two crawlers, one for each path, and then point each search bar accordingly. I don’t seem to be able to configure the Netlify Crawler such that it would create two indices though?
  2. Query Time Filtering: At query-time, somehow define a filter that only returns results with the url containing /handbook or /docs accordingly. I believe this is possible with a custom search bar (and not using the algoliasearchNetlify() setup), but not sure how I can apply the filter, even with something like instanceSearch.js?

If there is anyway of “easily” doing this with the Netlify plugin, that’d be great. All help appreciated! Thanks.

Hi @joepavitt, the best would be to have a property in your records identifying the section that would allow you to do faceting.
The Netlify plugin doesn’t expose a lot of configuration options unfortunately. Maybe you could leverage the keywords, or the category attributes, by adding the expected meta tags to your website.

Thanks Sylvain, appreciate the suggestion, have given it a go and it works great!

<meta property="article:section" content="<value-here>" />

was the key to getting the category set by the Netlify crawler

1 Like

You could create two separate indices for your product documentation and company handbook and then use the relevant index for each search bar. To do this, you could use the Algolia Netlify plugin to automatically index both /handbook/* and /docs/* pages into separate indices.

Thanks @ewordjohn99 - not entirely sure I know how I’d do this? The Netlify plugin doesn’t (obviously) allow for part indexing?