• Stars
    star
    170
  • Rank 223,357 (Top 5 %)
  • Language
    Ruby
  • License
    Academic Free Lic...
  • Created over 16 years ago
  • Updated about 13 years ago

Reviews

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

Repository Details

Ruby on Rails configurator and client to the Sphinx full text search engine

Ultrasphinx

Ruby on Rails configurator and client to the Sphinx full text search engine.

DEPRECATED¶ ↑

Please use Thinking Sphinx instead.

License¶ ↑

Copyright 2007-2008 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file. Some portions copyright Pat Allan, distributed under the MIT license, and used with permission. Some portions copyright PJ Hyett and Mislav Marohnić, distributed under the MIT license, and used with permission.

Requirements¶ ↑

  • MySQL 5.0, or PostgreSQL 8.2

  • Sphinx 0.9.8-rc2

  • Rails 2.0.2

More recent versions than listed are usually ok.

Features¶ ↑

Sphinx/Ultrasphinx is the fastest and most stable Rails fulltext search solution.

Features include:

  • searching and ranking across multiple models

  • delta index support

  • excerpt highlighting

  • Google-style query parser

  • spellcheck

  • faceting on text, date, and numeric fields

  • field weighting, merging, and aliasing

  • geodistance

  • belongs_to and has_many includes

  • drop-in compatibility with will_paginate

  • drop-in compatibility with Interlock

  • multiple deployment environments

  • comprehensive Rake tasks

And some other things.

Usage¶ ↑

Installation¶ ↑

First, install Sphinx itself. Get the 0.9.8 snapshot, then run ./configure, make, and sudo make install. Make sure to set your ./configure flags: ----prefix if necessary, and also ----with-pgsql if you need Postgres support.

You also need the chronic gem:

sudo gem install chronic

Then, install the plugin:

script/plugin install git://github.com/fauna/ultrasphinx.git

Next, copy the examples/default.base file to RAILS_ROOT/config/ultrasphinx/default.base. This file sets up the Sphinx daemon options such as port, host, and index location.

If you need per-environment configuration, you can use RAILS_ROOT/config/ultrasphinx/development.base, etc. Note that ERb is also allowed within the .base files, and can be an alternative way to DRY up multiple configurations.

Now, in your models, use the is_indexed method to configure a model as searchable. For example:

class Post
  is_indexed :fields => ['created_at', 'title', 'body']
end

For more index options, see ActiveRecord::Base .is_indexed.

Building the index¶ ↑

Now run:

rake ultrasphinx:configure
rake ultrasphinx:index
rake ultrasphinx:daemon:start

To rotate the index, just rerun rake ultrasphinx:index. If the search daemon is running, it will have its index rotated live. Otherwise the new index will be installed but the daemon will remain stopped.

Running queries¶ ↑

Query the daemon as so:

@search = Ultrasphinx::Search.new(:query => @query)
@search.run
@search.results

For more query options, including excerpt mode, see Ultrasphinx::Search.

Extras¶ ↑

Pagination¶ ↑

Once the @search object has been run, it is directly compatible with the will_paginate view helper. In your view, just do:

<%= will_paginate(@search) %>

Spell checking¶ ↑

See Ultrasphinx::Spell.

Delta indexing¶ ↑

Delta indexing speeds up your updates by not reindexing the entire dataset every time.

First, in your .base file, set the indexer option delta to your maximum interval between full reindexes. A day or a week is good, depending. Add a little bit to account for the time it takes the actual index to run:

delta = <%= 1.day + 30.minutes %>

Now, configure your models for delta indexing in the is_indexed call:

is_indexed :fields => ['created_at', 'title', 'body'],
  :delta => true

Now you can run rake ultrasphinx:index:delta frequently, and only records that were changed within 1 day will be reindexed. You will need to run rake ultrasphinx:index:main once a day to move the delta contents into the main index.

See ActiveRecord::Base .is_indexed and DEPLOYMENT_NOTES for more.

Available Rake tasks¶ ↑

See RAKE_TASKS.

Deployment notes¶ ↑

See DEPLOYMENT_NOTES.

Gotchas¶ ↑

Note that since Ultrasphinx preloads indexed models, you need to make sure those models have their own dependencies in place early in the boot process. This may require adjusting the general plugin load order or moving monkey-patches from lib/ to vendor/plugins/.

PostgreSQL 8.2 and higher are well supported. However, make sure the stored procedure migration gets generated correctly. If you did not install the plugin via script/install, run script/generate ultrasphinx_migration by hand.

Reporting problems¶ ↑

The support forum is here.

Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC.

Further resources¶ ↑

More Repositories

1

has_many_polymorphs

An ActiveRecord plugin for self-referential and double-sided polymorphic associations.
Ruby
202
star
2

bleak_house

A Ruby library for finding memory leaks
Ruby
189
star
3

mongrel

Mongrel
Ruby
144
star
4

peep

A heap inspector for live memcached instances.
Ruby
104
star
5

echoe

A Rubygems packaging tool that provides Rake tasks for documentation, extension compiling, testing, and deployment
Ruby
82
star
6

interlock

A Rails plugin for maintainable and high-efficiency caching
Ruby
75
star
7

ccsv

A pure-C CSV parser for Ruby
Ruby
64
star
8

raspell

A Ruby binding for the Aspell spelling checker
C
59
star
9

sweeper

A Ruby script to automatically tag your music collection with metadata from Last.fm
Ruby
32
star
10

thrift-rb

Ruby bindings for Thrift, with patches.
Ruby
18
star
11

allison

A modern, pretty RDoc template
Ruby
11
star
12

sinatra-jar

Sample monolithic dependency-free Sinatra JAR
Ruby
11
star
13

heroku-hello-world-tests

Ruby
9
star
14

kirby

A super-clean IRC bot with sandboxed Ruby evaluation, repository watching, and link-logging to del.icio.us
Ruby
9
star
15

benchmark_unit

Machine-independent benchmark assertions for your Ruby unit tests
Ruby
7
star
16

fftw3

Gem version of T. Horinouchi's ruby-fftw3.
C
7
star
17

rv

A little init.d system for running Camping apps
Ruby
6
star
18

twist

A Ruby script for logging your system events to Twitter
Ruby
6
star
19

mysqlconfs

MySQL configuration examples
5
star
20

charm_http

A parallel EC2 driver for running the hummingbird HTTP load testing tool against Heroku.
Ruby
4
star
21

shadow

A zero-configuration RESTful ActiveRecord server
Ruby
3
star
22

autobench-grapher

Ruby
2
star
23

wordpress_importer

Script that can import a homegrown blog into WXR format for WordPress.com.
Ruby
1
star
24

cloudbur.st

Cloudbur.st static assets
HTML
1
star
25

js-node

JavaScript
1
star
26

bax

A hacky blog engine that runs via recursive SSI includes
Ruby
1
star
27

scala-finagle

Scala
1
star
28

search_benchmark

Ruby
1
star
29

stub

A stub gem, including C extension.
Ruby
1
star