Skip to content

Commit

Permalink
Add sanitize_sql to indexes page
Browse files Browse the repository at this point in the history
  • Loading branch information
mtodd committed Apr 26, 2011
1 parent 9ee3223 commit 1ac39b1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ts/en/indexing.textile
Expand Up @@ -101,6 +101,22 @@ define_index do
end
{% 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])
end
{% 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.
Expand Down

0 comments on commit 1ac39b1

Please sign in to comment.