The Sphinx Client API is used to communicate with searchd daemon and get search results from Sphinx. It is used in large applications with a lot of data to provide fast, reliable search engine. Ruby API is a port of PHP API, which could be found inside your Sphinx distributive. Below you could find information on how to install and use it.
Warning: If you used this plugin before version 0.3.0 released, check the documentation, because I have fixed any differences between PHP and this API implementation, and all functions has been renamed.
Installation
Sphinx Client API for Ruby has been implemented as plugin for Ruby on Rails (but you able to use it in standalone Ruby application as well, there are no dependencies on other libraries). All you need is to download plugin sources and unpack them to the vendor/plugins/sphinx directory.
Documentation
You can find documentation here. Also you can build the documentation by running following command inside the vendor/plugins/sphinx directory:
Here is short example:
@sphinx.SetSortMode(Sphinx::Client::SPH_SORT_ATTR_ASC, 'created_at')
results = @sphinx.Query('test')
puts "Searched for:"
results['words'].each do |word, info|
puts " #{word} found #{info['hits']} times in #{info['docs']} documents"
end
print "\nResults #{results['total']} of #{results['total_found']}; "
puts "Total time: #{results['time']}"
results['matches'].each do |doc|
puts "Document ##{doc['id']} (weight #{doc['weight']}):"
doc['attrs'].each do |attr, value|
puts " #{attr}: #{value}"
end
end
Download
The latest version of “Sphinx Client API” is 0.3.1, and it can be downloaded here:
version0.3.1DownloadSphinx Client API
Also you can download client library for current Sphinx 0.9.8 r1112 development snapshot here: Sphinx Client API v0.4.0-r1112. WARNING, this is a current development snapshot rather than tested and approved release. Even though it is already used in production at some sites, it still has some known issues, and might have showstopper ones, too. Please use with care and do report any issues you might run into.
If you have any proposals, want to send feedback or found bugs, please post comments. It’s very important for me!
Changelog
- v0.3.1 (Dec 9, 2007)
- Fixed bug with search results sorting order.
- v0.3.0 (Apr 3, 2007)
- Fixed bug with processing attributes in query response (thanks to shawn).
- Fixed bug query processing time round-up (thanks to michael).
- API updated in compliance with PHP API for Sphinx 0.9.7.
- RSpec tests added
- v0.2.0 (Dec 20, 2006)
- Imporved exceptions handling.
- API updated in compliance with PHP API for Sphinx 0.9.7 RC2.
- v0.1.0 (Nov 26, 2006)
- Initial plugin implementation.
Other plugins
Full list of plugins I have implemented is available here.
Русский
English
Hi, I have a huge data in MySQl. Before I found Sphinx, I intend to build my old indexes and then build a tag cloud base on those indexes.
Now I wonder, can Sphinx and Client API help me in building tag cloud base on Sphinx indexes ?
Sorry, in the previous comment. I mean “my own indexes”, not “my old indexes”.
!
My English is not good
[...] - Rails wrapper for Ruby API for Sphinx, a full-text search [...]
[...] I have a good news: Sphinx Client API has been updated and now it supports all brand new features of the unstable Sphinx 0.9.8 development snapshot. What does it mean for you as a developer? What features you will get if you would decide to switch to the new version? I will describe most valuable improvements of the Sphinx in this article, and will show how to use them with new Sphinx Client API 0.4.0 r909. [...]