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
Site Search Documentation / tutorials: How to use the Swiftype Full-text Search Heroku Add-on

How to use the Swiftype Full-text Search Heroku Add-on

The Swiftype Heroku Add-on is a simple way to start working with the Swiftype API from your Heroku app.

Step 1: Provision the Swiftype Add-on in your Heroku App

There is no need to sign up for a Swiftype account first — this step automatically creates a Swiftype account for you as part of the provisioning process.

$ heroku addons:add swiftype

Step 2: Check your Heroku config

If the Swiftype add-on was successfully provisioned, you should see a new configuration value in your Heroku config: SWIFTYPE_URL.

$ heroku config | grep SWIFTYPE_URL

Step 3: Replicate your configuration locally

After provisioning the add-on it’s necessary to locally replicate the config vars so your development environment can operate against the service.

Use Forman to reliably configure and run the process formation specified in your app's Procfile. Foreman reads configuration variables from an .env file.

Your Swiftype search engine is like a database, so we recommend creating separate Swiftype engines for each server environment and developer so updates and deletes do not conflict with each other.

Use the following command to add the SWIFTYPE_URL value retrieved from heroku config to .env.

$ heroku config -s | grep SWIFTYPE_URL >> .env
$ more .env

Step 4: Add the Swiftype Gem to your Rails app

The easiest way to get started using Swiftype with Rails is to follow our Rails integration tutorial.

Ruby on Rails applications will need to add the following entry into their Gemfile specifying the Swiftype client library.

gem 'swiftype', '~> 1.0.0'

Update application dependencies with bundler.

$ bundle install

Create a configuration file at config/swiftype.rb, and add configuration information:

Swiftype.authenticated_url = ENV['SWIFTYPE_URL']

Step 5: Interact with the Swiftype API from your controllers and models

You're now ready to start making calls to the Swiftype API from controllers or model callbacks. See our Swiftype Ruby gem for examples, as well as the detailed API documentation for an exhaustive review of the available functionality.

For the Heroku add-on, your engine slug (used in API calls) will always be "engine". You'll need to create one or more DocumentTypes via the API to store your Documents.

The swiftype-rails-example project provides a good starting point for building a Rails-based application.

Step 6: Open the Swiftype Dashboard to customize your search engine

The dashboard can be accessed via the CLI:

$ heroku addons:open swiftype
Opening swiftype for sharp-mountain-4005...