background preloader

Sphinx

Facebook Twitter

Searching § Thinking Sphinx. Edit via Gyoza Basic Searching Once you’ve got an index set up on your model, and have the Sphinx daemon running, then you can start to search, using a method on your model named just that. Article.search 'pancakes' Sphinx does have some reserved characters (including the @ character), so you may need to escape your query terms. Riddle (a dependency of Thinking Sphinx) has escaping methods built-in: # For Thinking Sphinx v3 or newer:Article.search Riddle::Query.escape(params[:query])# For Thinking Sphinx before v3:Article.search Riddle.escape(params[:query]) Please note that Sphinx paginates search results, and the default page size is 20.

Field Conditions To focus a query on a specific field, you can use the :conditions option - much like in ActiveRecord (back before Rails 3, anyway): Article.search :conditions => {:subject => 'pancakes'} You can combine both field-specific queries and generic queries too: Article.search 'pancakes', :conditions => {:subject => 'tasty'} Attribute Filters :bm25. A Concise Guide to Using Thinking Sphinx : Freelancing Gods.

Okay, it’s well past time for the companion piece to my Sphinx Primer – let’s go through the basic process of using Thinking Sphinx with Rails. Just to recap: Sphinx is a search engine that indexes data, and then you can query it with search terms to find out which documents are relevant. Why do you want to use it with Rails? Because it saves having to write messy SQL, and it’s so damn fast. (If you’re getting a feeling of deja-vu, then it’s probably because you’ve read an old post on this blog that dealt with an old version of Thinking Sphinx. Installation So: first step is to install Sphinx. Curl -O tar zxvf sphinx-0.9.8-rc2.tar.gz cd sphinx-0.9.8-rc2 . If you’re using Windows, you can just grab the binaries. Once that’s taken care of, you then want to take your Rails app, and install the plugin. Script/plugin install Otherwise, you’ve got a couple of options. Configuration Change. Deploying a Rails app with Thinking Sphinx.

For the past few years I’ve been working with Stephen P. Anderson on a few things. The Mental Notes card deck is a brainstorming tool. “Each card describes one insight into human behavior and suggests ways to apply this to the design of Web sites, Web apps, and software applications.” In addition to those, we’ve launched a few sites for a client. After The Meeting is a site that helps you focus on what typically happens not during a meeting, but after. It helps attendees keep track of what action items they were assigned and pokes you at times to get them done if you’re running late. Part of After the Meeting is a way to make a formal agreement with someone.

Promise Play takes those formal agreements out of meetings so it’s just you and one of your Facebook friends. Other than that, I’m slowly working on a redesign of this site and looking forward to a project that’s been on the back-burner for a little while. Haven’t posted here in forever. See the slides on SpeakerDesk Restarting the App. Slash Dot Dash » Blog Archive » Rails searching with Sphinx. Over the weekend I was implementing search for trawlr.com using Sphinx, the nginx of the search world (fast and Russian) according to Evan Weaver.

Previously I was using Ferret, but I had to remove the search feature almost immediately due to the ferret indexes constantly corrupting and causing me a major headache. I decided to drop ferret in favour of Sphinx which I’ve lots of good things about recently. Installation on my MacBook Pro required a slight adjustment of the mysql directories with mysql5 from MacPorts. $ wget $ tar xvzf sphinx-0.9.7.tar.gz $ cd sphinx-0.9.7 $ . /configure --with-mysql-includes=/opt/local/include/mysql5/mysql/ --with-mysql-libs=/opt/local/lib/mysql5/mysql/ $ make $ sudo make install Initally, I chose to use Evan’s UltraSphinx plugin and it was very helpful to start with by auto-generating the sphinx.conf. Having already looked at the alternative Sphinx plugins I decided to try acts_as_sphinx. Update. Using Sphinx search engine in Ruby on Rails | Dmytro Shteflyuk&#

Almost all Web-applications needs data search logic and really often this logic should have full-text search capabilities. If you are using MySQL database, you can use its FULLTEXT search, but it’s not efficient when you have a large amout of data. In this case third party search engines used, and one of them (and I think, the most efficient) is Sphinx. In this article I’ll present my port of Sphinx client library for Ruby and show how to use it. First of all, what is the Sphinx itself? Current Sphinx distribution includes the following software: indexer: an utility to create fulltext indices;search: a simple (test) utility to query fulltext indices from command line;searchd: a daemon to search through fulltext indices from external software (such as Web scripts);sphinxapi: a set of API libraries for popular Web scripting languages (currently, PHP); First you need to download plugin from RubyForge, or from this site.

It’s pretty simple, isn’t it? Comments are closed. Sphinx - Free open-source SQL full-text search engine.