GithubHelp home page GithubHelp logo

evan / ultrasphinx Goto Github PK

View Code? Open in Web Editor NEW
170.0 3.0 36.0 3.66 MB

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

Home Page: http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/

License: Academic Free License v3.0

Ruby 99.90% JavaScript 0.10%

ultrasphinx's Introduction

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

ultrasphinx's People

Contributors

aslakhellesoy avatar bridiver avatar ellingbo avatar etuhoha avatar evan avatar ihoka avatar monde avatar noahd1 avatar pdcawley avatar smulube avatar tomstuart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ultrasphinx's Issues

partial word searches?

hi.

i've set in default.base

enable_star = 1 
min_prefix_len = 4

then i re-ran rake ultrasphinx:configure, restarted the daemon and even reindexed all using rake.

all that to say, i can see in my autogenerated development.conf file the settings are there, but when i use my search form in my view and controller, partial words don't appear.

i expected to be able to search the word "CORN" and come up with "CORNHUSKER", "CORNHOLD" etc... only none of these show up. All that works is whole word searching. How am i screwing this up? thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.