• This repository has been archived on 12/Apr/2022
  • Stars
    star
    1,061
  • Rank 41,937 (Top 0.9 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 13 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unmaintained, use Soulheart!

Soulmate is no longer being actively maintained. For a similar project that is still actively developed, check out soulheart

Soulmate

Soulmate is a tool to help solve the common problem of developing a fast autocomplete feature. It uses Redis's sorted sets to build an index of partially completed words and the corresponding top matching items, and provides a simple sinatra app to query them. Soulmate finishes your sentences.

Soulmate was designed to be simple and fast, and offers the following:

  • Provide suggestions for multiple types of items in a single query (at SeatGeek we're autocompleting for performers, events, and venues)
  • Results are ordered by a user-specified score
  • Arbitrary metadata for each item (at SeatGeek we're storing both a url and a subtitle)

An item is a simple JSON object that looks like:

{
  "id": 3,
  "term": "Citi Field",
  "score": 81,
  "data": {
    "url": "/citi-field-tickets/",
    "subtitle": "Flushing, NY"
  }
}

Where id is a unique identifier (within the specific type), term is the phrase you wish to provide completions for, score is a user-specified ranking metric (redis will order things lexicographically for items with the same score), and data is an optional container for metadata you'd like to return when this item is matched (at SeatGeek we're including a url for the item as well as a subtitle for when we present it in an autocomplete dropdown).

See Soulmate in action at SeatGeek.

Getting Started

As always, kick things off with a gem install:

gem install soulmate

Loading Items

You can load data into Soulmate by piping items in the JSON lines format into soulmate load TYPE.

Here's a sample venues.json (one JSON item per line):

{"id":1,"term":"Dodger Stadium","score":85,"data":{"url":"\/dodger-stadium-tickets\/","subtitle":"Los Angeles, CA"}}
{"id":28,"term":"Angel Stadium","score":85,"data":{"url":"\/angel-stadium-tickets\/","subtitle":"Anaheim, CA"}}
{"id":30,"term":"Chase Field ","score":85,"data":{"url":"\/chase-field-tickets\/","subtitle":"Phoenix, AZ"}}
{"id":29,"term":"Sun Life Stadium","score":84,"data":{"url":"\/sun-life-stadium-tickets\/","subtitle":"Miami, FL"}}
{"id":2,"term":"Turner Field","score":83,"data":{"url":"\/turner-field-tickets\/","subtitle":"Atlanta, GA"}}

And here's the load command (Soulmate assumes redis is running locally on the default port, or you can specify a redis connection string with the --redis argument):

$ soulmate load venue --redis=redis://localhost:6379/0 < venues.json

You can also provide an array of strings under the aliases key that will also be added to the index for this item.

Querying for Data

Once it's loaded, we can query this data by starting soulmate-web:

$ soulmate-web --foreground --no-launch --redis=redis://localhost:6379/0

And viewing the service in your browser: http://localhost:5678/search?types[]=venue&term=stad. You should see something like:

{
  "term": "stad",
  "results": {
    "venue": [
      {
        "id": 28,
        "term": "Angel Stadium",
        "score": 85,
        "data": {
          "url": "/angel-stadium-tickets/",
          "subtitle": "Anaheim, CA"
        }
      },
      {
        "id": 1,
        "term": "Dodger Stadium",
        "score": 85,
        "data": {
          "url": "/dodger-stadium-tickets/",
          "subtitle": "Los Angeles, CA"
        }
      },
      {
        "id": 29,
        "term": "Sun Life Stadium",
        "score": 84,
        "data": {
          "url": "/sun-life-stadium-tickets/",
          "subtitle": "Miami, FL"
        }
      }
    ]
  }
}

The /search method supports multiple types as well as an optional limit. For example: http://localhost:5678/search?types[]=event&types[]=venue&types[]=performer&limit=3&term=yank. You can also add the callback parameter to enable JSONP output.

Mounting soulmate into a rails app

If you are integrating Soulmate into a rails app, an alternative to launching a separate 'soulmate-web' server is to mount the sinatra app inside of rails.

Add this to routes.rb:

mount Soulmate::Server, :at => "/sm"

Add this to gemfile:

gem 'rack-contrib'
gem 'soulmate', :require => 'soulmate/server'

Then you can query soulmate at the /sm url, for example: http://localhost:3000/sm/search?types[]=venues&limit=6&term=kitten

You can also config your redis instance:

# config/initializers/soulmate.rb

Soulmate.redis = 'redis://127.0.0.1:6379/0'
# or you can asign an existing instance of Redis, Redis::Namespace, etc.
# Soulmate.redis = $redis

Rendering an autocompleter

Soulmate doesn't include any client-side code necessary to render an autocompleter, but Mitch Crowe put together a pretty cool looking jquery plugin designed for exactly that: soulmate.js.

Contributing to soulmate

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2011 Eric Waller. See LICENSE.txt for further details.

More Repositories

1

fuzzywuzzy

Fuzzy String Matching in Python
Python
9,067
star
2

react-infinite

A browser-ready efficient scrolling container based on UITableView
JavaScript
2,714
star
3

thefuzz

Fuzzy String Matching in Python
Python
2,460
star
4

SGImageCache

A flexible image caching library for image rich iOS applications
Objective-C
401
star
5

android-PlacesAutocompleteTextView

An address-autocompleting text field for Android
Java
281
star
6

djjob

PHP port of delayed_job, a database backed asynchronous priority queue
PHP
253
star
7

hashi-helper

Disaster Recovery and Configuration Management for Consul and Vault
Go
184
star
8

nomad-helper

Useful tools for working with @hashicorp Nomad at scale
Go
157
star
9

docker-mirror

Mirror docker images across image repositories
Go
140
star
10

nomad-firehose

Firehose all nomad job, allocation, nodes and evaluations changes to rabbitmq, kinesis or stdout
Go
115
star
11

bash-aptfile

A simple method of defining apt-get dependencies for an application
Shell
89
star
12

businesstime

A simple python utility for calculating business time aware timedeltas between two datetimes
Python
85
star
13

react-slider

DEPRECATED: A Slider in React
JavaScript
80
star
14

docker-build-cacher

Builds a service with docker and caches the intermediate stages
Haskell
53
star
15

druzhba

Python
36
star
16

conductor

A data-backed adwords campaign bidder
Python
25
star
17

backstage-plugins

SeatGeek Backstage Plugins Collection
TypeScript
25
star
18

haldane

a friendly http interface to the aws api
Python
23
star
19

dhall-nomad

Create maintainable nomad job files
Dhall
22
star
20

SGHTTPRequest

Objective-C
17
star
21

aws-dynamic-consul-catalog

Keep your Consul service catalog in sync with your RDS instances
Go
16
star
22

tornado-async-transformer

libcst transformer that replaces tornado's legacy @gen.coroutine syntax with python3.5+ native async/await
Python
15
star
23

amqp-dispatcher

A daemon to run AMQP consumers
Python
14
star
24

statsd_rb

DEPRECATED. Use https://github.com/etsy/statsd instead of this.
Ruby
13
star
25

hell

Deprecated: Hell is an open source web interface that exposes a set of capistrano recipes as a json api, for usage within large teams
JavaScript
12
star
26

redis-health

Can be used to check the health of your Redis instance.
Go
12
star
27

SGAPI

The SG Api SDK for iOS
Objective-C
11
star
28

SGListAnimator

Provides animated transitions for your table and collection views, so you don't have to resort to calling `reloadData`.
Objective-C
10
star
29

api-support

A support channel for the SeatGeek Platform
8
star
30

react-select-option

A plain <select> component that can be styled.
JavaScript
8
star
31

circus-logstash

A Circus logger for shipping logs to Logstash
Python
6
star
32

nomad-crashloop-detector

detect Nomad allocation crash-loops, by consuming the allocation stream from nomad-firehose
Go
5
star
33

gramo

Kotlin
5
star
34

datadog-service-helper

use consul catalog to manage datadog service checks
Go
4
star
35

wrecker-ui

An HTML interface for wrecker, the load testing tool
Elm
4
star
36

graceful_listener

net.Listener implementation for graceful shutdown
Go
4
star
37

sgcli

A command-line interface for SeatGeek
Python
4
star
38

logrus-gelf-formatter

Formats logrus messages in the GELF JSON format
Go
3
star
39

geocoder-java

Fork of https://code.google.com/p/geocoder-java/
Java
3
star
40

homebrew-formulae

Custom SeatGeek Formula for Homebrew
Ruby
3
star
41

k8s-reconciler-generic

A generic Kubernetes reconciler abstraction based on kubebuilder
Go
3
star
42

sgmods-go

Codemods for golang from SeatGeek.
Go
1
star
43

api-intro-presentation

1
star
44

greenhouse-api-client

Kotlin
1
star
45

seatgeek-emea-ios-sdk

Swift
1
star
46

elastic-search-health

Go
1
star
47

vault-stress

Go
1
star
48

sfn-stack-profile

Ruby
1
star
49

eslint-config-seatgeek-react-standard

React rules specific to the SeatGeek repositories.
JavaScript
1
star