Filtering results based on URL path

On our documentation site, we have different versions of the documentation based on paths. For example, /docs/v1/... and /docs/v2/....

Looking at the index data, I can see these pages are being indexed, but I am not seeing how I can send a search query to only bring back the results of whatever version the user is on (determined by the current URL path). On the front end, I can handle the results and just remove the ones where the path is not a match for the user, but ideally I’d like to do this through querying.

Do I need to setup a facet in the crawler to capture the URL so I can filter on that?

That’s exactly right. You can build a recordExtractor function to parse the version info and inject it as a filterable attribute on your documentation records.

Here’s some boilerplate from the DocSearch docs:

And here’s some additional info in the Crawler docs: