How can I weight search results based on a URL regular expression?



On our docs site we have many similar pages for multiple versions of the product.

I’d like to weight the most recent version the highest and push previous versions down in the list of results. Just going by when the page was updated doesn’t always reflect what version of the product the page is about.

Since the URL contains the version, would it be possible to add score relevance based on a fragment or regex of the page URL?

We don’t currently have a way to prefer results by a URL pattern (though you can exclude pages entirely by URL, see our documentation on path inclusion/exclusion).

The best way to do this would be to add a meta tag for a new field, something like this:

<meta class="swiftype" name="product_version" data-type="float" content="3.2" />

Then add a functional boost on that field to increase the score of documents with a higher value for the product_version field. You can accomplish this by way of our API (see the section on functional boosts) or by using the Weights tab.