search mobile facets autocomplete spellcheck crawler rankings weights synonyms analytics engage api customize documentation install setup technology content domains user history info home business cart chart contact email activate analyticsalt analytics autocomplete cart contact content crawling custom documentation domains email engage faceted history info install mobile person querybuilder search setup spellcheck synonyms weights engage_search_term engage_related_content engage_next_results engage_personalized_results engage_recent_results success add arrow-down arrow-left arrow-right arrow-up caret-down caret-left caret-right caret-up check close content conversions-small conversions details edit grid help small-info error live magento minus move photo pin plus preview refresh search settings small-home stat subtract text trash unpin wordpress x alert case_deflection advanced-permissions keyword-detection predictive-ai sso

Multiple Domains Guide

"How can I search across multiple domains?"

This guide will demonstrate how to set-up Site Search with multiple domains.

You might have content located within various subdomains...

  • blog.example.com
  • community.example.com
  • store.example.com

Or you might have several different domains:

  • example.com
  • anotherexample.com
  • athirdexample.com

With all your content spread around, what if you want a centralized search experience?

One search experience to rule them all, so to speak!

The solution involves meta tags.

Note: Multiple domains are available within Pro and Premium plans.

Adding Multiple Domains

But first: how to add a second domain.

During signup, you add your first domain.

After that, adding a second one can be done in two ways...

Adding a domain: Dashboard

Login to the Site Search dashboard.

Locate the Domains option within the left hand menu.

Click into it, and note the ADD A DOMAIN button in the top right:

Add Domain - The big green button.
A picture of the dashboard, where the ADD A DOMAIN button is visible.

You will then be prompted to add your domain.

Add it, like so, addressing any errors that may appear:

Add Domain - Entering the URL
Adding a URL into the shiny and neat URL addition screen.

Adding a domain will initiate a crawl; its pages will be indexed.

Adding a domain: API

You can also use the API to add a domain.

Send in your auth_token along with a domain object containing the new URL:

curl -X POST 'https://api.swiftype.com/api/v1/engines/[ENGINE_NAME]/domains.json' \
  -H 'Content-Type: application/json' \
  -d '{
        "auth_token": "YOUR_API_KEY",
        "domain": {"url": "https://seconddomain.com"}
      }'

That's it! A crawl will then take place to index the domain's pages.

Organize & Search

If we stopped here, we'd have one Engine containing all of our domains' documents.

They are in different sites, but they exist "as one" within your Site Search Engine.

What if you want to search, filtering by domain?

The answer lies within meta tags.

A meta tag creates a new field within your documents.

Consider we have three domains:

  1. example1.com
  2. example2.com
  3. example3.com

Within each domain, we would place a meta tag unique to that domain.

A recommended pattern is to create an integer tag called domain-identifier.

You would use this new field to filter by domain.

The content of each tag should be a simple number between 1 and n, where n is the total number of domains.

eg. example1.com's pages would have this tag within all pages:

<meta class="swiftype" name="domain-identifier" data-type="integer" content="1" />

example2.com's pages would have this tag within all pages:

<meta class="swiftype" name="domain-identifier" data-type="integer" content="2" />

And so on!

You can then apply a filter on the domain-identifier field values:

curl -XGET 'https://search-api.swiftype.com/api/v1/public/engines/search.json' \
  -H 'Content-Type: application/json' \
  -d '{
        "engine_key": "YOUR_ENGINE_KEY",
        "q": "example query",
        "filters":{
          "page":{
            "domain-identifier": "1"
          }
        }
      }'

What if you want to prioritize search results by domain?

A great pattern to use involves a site-priority meta tag.

You would use this to get results from one domain first.

<meta class="swiftype" name="site-priority" data-type="integer" content="5" />

If you had one high priority domain, and many lower priority domains...

eg. example1.com is high priority:

<meta class="swiftype" name="site-priority" data-type="integer" content="2" />

example2.com, example3.com, example4.com are low priority:

<meta class="swiftype" name="site-priority" data-type="integer" content="1" />

You can apply a boost to determine domain order.

The following would multiply the relevance score of each document by the site-priority value:

curl -XGET 'https://search-api.swiftype.com/api/v1/public/engines/search.json' \
  -H 'Content-Type: application/json' \
  -d '{
        "engine_key": "YOUR_ENGINE_KEY",
        "q": "example query",
        "functional_boosts":{
          "page":{
            "site-priority": "linear"
          }
        }
      }'

Documents within example1.com would be considered twice as valuable, appearing first.

Site Search is an excellent solution for searching over multiple domains.

With the knowledge of these two patterns, you can search across multiple domains however you wish.


Stuck? Looking for help? Contact support or check out the Site Search community forum!