How to do this in Site Search

We’re using crawler-based site search for our product documentation, and it works fine. However, we’d like to provide access to documentation for our previous versions, each of which is stored in a subdirectory of our docs web.

We currently have those subdirectories excluded in the crawl rules, because we don’t want searches to find results in the current And previous versions. So, for example, if you’re looking at the v2.5 docs subdirectory, your searches would return results only in the 2.5 docs, and if you’re looking at the 2.6 docs directory, your searches only look within there.

If it were free, I could just create a separate engine for each version’s subdirectory. What would be a way to do this without creating an engine per version?

Thanks in advance,

Hey Gary,

Great question! This is a great use case for using meta-tags and filtering. For setting the tags, you could define a custom tag for the documentation version of that page.


<meta class="swiftype" name="version" data-type="enum" content="2.5" />

Then for straight-forward, contextual based filtering, you could then modify the standard embed script based on the section of the site the end-user is searching from. Here’s a gist of that syntax: v2 Embed Filtering · GitHub

For more advanced filtering/implementations we recommend using our jQuery client(s): Swiftype API Client Libraries | Swiftype

We’re using swiftype in a documentation web built with Jekyll. I build
and test the web locally on my Mac; when release time comes, I upload it to
doc.splicemachine .com for customers, or to docstest.splicemachine .com for
internal use. For this effort, I’m building and working with the docstest

Searches in my local version are linking to the previously-crawled
docstest engine (recrawled yesterday).

Test Goal:
I want to limit search results to only pages that have a specific value
(2.7) in the ‘buildversion’ metatag.


On, add this tag to just a handful of pages:

Is on these pages on docstest.splicemachine .com:
    docstest.splicemachine .com/sqlref_statements_altertable.html
    docstest.splicemachine .com/sqlref_statements_createrole.html
    docstest.splicemachine .com/sqlref_statements_revoke.html
    docstest.splicemachine .com/tutorials_connect_cognos.html
    docstest.splicemachine .com/developers_fundamentals_triggers.html
    docstest.splicemachine .com/cmdlineref_run.html
    docstest.splicemachine .com/dbaas_cmd_initialstartup.html
    docstest.splicemachine .com/onprem_install_cloudera.html

The other 500+ pages do not contain that tag.

After adding those tags last night, I re-indexed each of those 8 pages.

In the local build (on my mac, not live on docstest), every page contains
this swiftype script:

<script type="text/javascript">


_st('install','<docstest engine id is here>','2.0.0', {
  install: {
    hooks: {
      query_filter: function(query) {

‘buildversion’, { values: [ ‘2.7’], type: “and” });

        return query;

According to my understanding, when I search in my local build with this
script in place, the search results should only include pages that contain
the ‘buildversion’ metatag set to value=‘2.7’.

But what I’m seeing is that the results of local searches are including all
pages. Either I’m missing something, or my understanding of what should
happen is wrong.

Can you help?

Did you ever manage to get this working? I’m trying to do something like this, but cannot find an example anywhere:

_st('install','SWIFTYPE-ENGINE-CODE','2.0.0', {
    filters: {'page': {'tags': 'Forum'}}

Any help is much appreciated :pray:

Sorry for the delay in responding; busy week. I did get this working. My script looks like this:

The “site.build_version” Liquid variable is assigned the build version when my docs web gets built. That setFilter statement tells Swiftype to only look at pages that have the metadata value buildversion set to my desired version.

And then each page in my web has a tag like this:

So when I build my docs system for version 2.5, I set the content tag for all pages to “2.5”, for 2.7, I set it to “2.7” etc. Then Swiftype will only examine pages that are set to the desired value.

I build a subdirectory named 2.5 with site.build_version=“2.5”, and I build a subdirectory named 2.7 with site.build_version=“2.7”, all using (pretty much) the same source pages and same build scripts.

I hope that makes some sense…