Browse files

Merged pull request #4 from mtodd/sanitize_sql.

Add sanitize_sql to indexes page
  • Loading branch information...
2 parents 9ee3223 + 1ac39b1 commit c29da29b7c4182326e22ae65d197bf076ee2c514 @pat committed Apr 30, 2011
Showing with 16 additions and 0 deletions.
  1. +16 −0 ts/en/indexing.textile
16 ts/en/indexing.textile
@@ -101,6 +101,22 @@ define_index do
{% endhighlight %}
+h3. SQL
+As previously mentioned, your index definition results in SQL from the indexes, the attributes, conditions and groupings, etc. With this in mind, it may be useful to simplify your index.
+One way would be to use something like @ActiveRecord::Base.sanitize_sql@ to generate the required SQL for you. For example:
+{% highlight ruby %}
+define_index do
+ # ...
+ where sanitize_sql(["published", true])
+{% endhighlight %}
+This will produce the expected @WHERE published = 1@ for MySQL.
h3. Processing your Index
Once you've got your index set up just how you like it, you can run "the rake task":rake_tasks.html to get Sphinx to process the data.

0 comments on commit c29da29

Please sign in to comment.