CARVIEW |
Every repository with this icon (

Every repository with this icon (

Run the following if you haven't already:
gem sources -a https://gems.github.com
Install the gem(s):
sudo gem install freelancing-god-riddle
Description: | Client API for Sphinx |
Homepage: | https://riddle.freelancing-gods.com |
Clone URL: |
git://github.com/freelancing-god/riddle.git
Give this clone URL to anyone.
git clone git://github.com/freelancing-god/riddle.git
|
tree 442919d3edba9cf043ad2ee2b87c4ea656c07612
parent 5f356aa39e7f0e308c26aeb3ff8126ebda96ea4f
name | age | message | |
---|---|---|---|
![]() |
.gitignore | Sun Nov 09 06:15:15 -0800 2008 | Starting to add some more specs [freelancing-god] |
![]() |
MIT-LICENCE | Wed Nov 14 03:23:27 -0800 2007 | The licence file should probably have the licen... [freelancing-god] |
![]() |
README | Wed Nov 05 00:54:33 -0800 2008 | Code cleanup, courtesy of Henrik [freelancing-god] |
![]() |
README.textile | Wed Nov 05 00:54:33 -0800 2008 | Code cleanup, courtesy of Henrik [freelancing-god] |
![]() |
Rakefile | Sat Nov 22 21:09:21 -0800 2008 | Adding gemspec generator and tabtab sphinx defi... [freelancing-god] |
![]() |
lib/ | Mon Jan 26 07:46:52 -0800 2009 | Handling errors from Riddle a bit better [freelancing-god] |
![]() |
riddle.gemspec | Tue Jan 20 19:54:48 -0800 2009 | Fixing handling of strings with new lines for s... [freelancing-god] |
![]() |
spec/ | Mon Nov 10 03:46:54 -0800 2008 | Adding a spec for configuration would be a good... [freelancing-god] |
This client has been written to interface with Sphinx. It is written by Pat Allan, and has been influenced by both Dmytro Shteflyuk’s Ruby client and the original PHP client – credit where credit’s due, after all.
It does not follow the same syntax as those two, though (not much point writing this otherwise) - opting for a more Ruby-like structure.
The easiest way to install is to grab the gem from GitHub:
sudo gem install freelancing-god-riddle --source https://gems.github.com/
However, if you’re so inclined, you can grab sourcecode.
git clone git://github.com/freelancing-god/thinking-sphinx.git
If you’re looking for old versions – for older versions of Sphinx – you’ll want to peruse the tagged versions in the old subversion repository
svn co https://rails-oceania.googlecode.com/svn/patallan/riddle/tags riddle-tags
Please note that at the time of writing, the following versions are supported (if you get the appropriate tag):
- 0.9.8-r871
- 0.9.8-r909
- 0.9.8-r985
- 0.9.8-r1065
- 0.9.8-r1112
- 0.9.8-rc1 (gem version: 0.9.8.1198)
- 0.9.8-rc2 (gem version: 0.9.8.1231)
- 0.9.8 (gem version: 0.9.8.1371)
To get started, just instantiate a Client object:
client = Riddle::Client.new # defaults to localhost and port 3312
client = Riddle::Client.new "sphinxserver.domain.tld", 3333 # custom settings
And then set the parameters to what you want, before running a query:
client.match_mode = :extended
client.query "Pat Allan @state Victoria"
The results from a query are similar to the other clients – but here’s the details. It’s a hash with the following keys:
- :matches
- :fields
- :attributes
- :attribute_names
- :words
- :total
- :total_found
- :time
- :status
- :warning (if appropriate)
- :error (if appropriate)
The key :matches
returns an array of hashes – the actual search results. Each hash has the
document id (:doc
), the result weighting (:weight
), and a hash of the attributes for
the document (:attributes
).
The :fields
and :attribute_names
keys return list of fields and attributes for the
documents. The key :attributes
will return a hash of attribute name and type pairs, and
:words
returns a hash of hashes representing the words from the search, with the number of
documents and hits for each, along the lines of:
results:words #=> {:docs => 12, :hits => 15}
:total
, :total_found
and :time
return the number of matches available, the
total number of matches (which may be greater than the maximum available), and the time in milliseconds
that the query took to run.
:status
is the error code for the query – and if there was a related warning, it will be under
the :warning
key. Fatal errors will be described under :error
.
If you’ve installed the gem and wondering why there’s no tests – check out the svn version. I’ve kept the specs out of the gem as I have a decent amount of test data in there, which really isn’t needed unless you want to submit patches.
Contributors
Thanks to the following people who have contributed to Riddle in some shape or form:
- Andrew Aksyonoff
- Brad Greenlee
- Lachie Cox
- Jeremy Seitz
- Mark Lane
- Xavier Noria
- Henrik Nye