Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An add-on gem for spelling suggestions in Thinking Sphinx
branch: master

This branch is 16 commits behind pat:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/thinking_sphinx
spec
tasks
.gitignore
LICENSE
README.textile
Rakefile
VERSION.yml
thinking-sphinx-raspell.gemspec

README.textile

Thinking Sphinx with Raspell

This library adds Aspell/Raspell support to Thinking Sphinx.

Installation

You’ll need the Aspell library (easily compiled by source, or installed via MacPorts). Don’t forget to install the English library as well – there’s instructions for both in Evan Weaver’s Raspell README.

Once that’s set up, grab the gem from GemCutter:

sudo gem install thinking-sphinx-raspell \
  --source http://gemcutter.org

You’ll want to add the gem to your config/environment.rb file (assuming you’re working on a Rails application):

config.gem('thinking-sphinx-raspell',
  :lib     => 'thinking_sphinx/raspell',
  :source  => 'http://gemcutter.org',
  :version => '>= 1.0.0'
)

Or, if you wish to do a manual require yourself:

require 'thinking_sphinx/raspell'

Usage

By default, Thinking Sphinx will not overwrite your search query, but you can view suggestions:

@articles = Article.search 'pnacakes'
@articles.suggestion? #=> true
@articles.suggestion  #=> 'pancakes'

You can also choose to redo the search using the provided suggestion:

@articles.redo_with_suggestion
@articles.each do |article|
  # ...
end

Configuration

You can customise the following settings – either in your config/environment.rb file, or perhaps in an initializer. Example syntax below highlights the current defaults.

config = ThinkingSphinx::Configuration.instance
config.raspell.dictionary             = 'en'
config.raspell.suggestion_mode        = :normal
config.raspell.options['ignore-case'] = true

You can look at the available options using the following two collections:

config = ThinkingSphinx::Configuration.instance
config.raspell.dictionaries     #=> ['en', 'en_GB', 'en_US', ... ]
config.raspell.suggestion_modes #=> [:ultra, :fast, :normal, :badspellers]

If you need more documentation, you can check out the YARD files on rdoc.info. This isn’t a big library, though – what you see in this readme is pretty much what you get.

Limitations

  • Only checks normal query strings, not field-specific queries via the :conditions hash.

Patches are very much welcome – I would like to address this last remaining limitation.

Copyright

Copyright © 2009 Pat Allan. Released under an MIT licence.

Something went wrong with that request. Please try again.