Code Monkey home page Code Monkey logo

ambitious-sphinx's Introduction

= An Ambitious Sphinx Adapter

I don't know about you, but I like me some sexy full-text searching.

== The basics

Want to find all meals that mention bacon?

  Meal.select {'bacon'}

What about bacon bits and sour cream?

  Meal.select {'bacon bits' && 'sour cream'}

Maybe with bacon in the name, or cheese in the recipe?

  Meal.select {|m| m.name =~ 'bacon' || m.recipe =~ 'cheese'}

Cheese in the name, but not grilled?

  Meal.select {|m| m.name =~ 'bacon' && m.name !~ 'grilled'}

== Pagination

You're going to want to use pagination. Ultrasphinx, the underlying library, only supports it, as in, you can't just get all the objects matching your query. You _have_ to use paging.

It's pretty simple:

  Meal.select {'bacon'}.page(2)
  Meal.select {'bacon'}.page(3)

== Big honking disclaimer

We're still learning a lot about how sphinx and ambition work, so things are likely to change a lot, and features are likely to be missing.

== Getting Started


=== Installing

  sudo gem install ambitious-sphinx
  
=== Add it to your app
    
Require our files somewhere, like at the end of config/environment.rb, maybe create config/initializers/sphinx.rb

  require 'ultrasphinx'
  require 'ambition/adapters/ambitious_sphinx'
  
=== Sphinx and Ultrasphinx
    
You will also need to go through the motions of setting up ultrasphinx.

This includes:

 * Configuring/installing sphinx
 * Modifying your model to indicate what's to be indexed
 * Bootstrapping ultrasphinx
 
All this is discussed in detail in ultrasphinx's README

== Playing with the code base

In addition to the other dependencies, you'll need to:

  gem install echoe redgreen mocha test-spec
  
Run the tests with:
  
  rake test
  

== More information on Sphinx:

 -> http://www.sphinxsearch.com/
 -> http://blog.evanweaver.com/articles/2007/07/09/ultrasphinx-searching-the-world-in-231-seconds/
 -> http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/files/README.html

== More information on Ambition:

-> http://ambition.rubyforge.org
-> http://groups.google.com/group/ambition-rb/

ambitious-sphinx's People

Contributors

technicalpickles avatar

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.