Merge branch 'release/v3.1.1' into develop
Allow casting of document ids pre-offset as bigints.

Set big_document_ids to true either via set_property in specific index definitions, or within config/thinking_sphinx.yml to impact all indices. See #610.
Continue to raise query errors immeditately - but don't hang onto the connection.

This may be the elusive fix to #704 - the inject error crops up immediately after the syntax error, as the query queue (from Sphinx's perspective) isn't cleared. So, two syntax errors in a row lead to an inject error.
Cleaner implementation of guard files for indexing.
Rebuild now uses the clear task between stopping the daemon and indexing.

This ensures TS index locking files are removed as well. Should help situations like in #778.
Default the Capistrano TS Rails environment to rails_env, fall back to stage.
When flagging records as deleted, process 1000 at a time.
Custom JoinAssociation class for Rails 4.1.
Rails 4.1 has an add_reflection method.

The reflections hash is computed afresh on each call, so we can't modify it. Hence, use the add_reflection method if it exists.
Rails 4.1 does not escape table names for join tables by default.
Use custom join association class where possible.

Essentially, this behaviour only has an impact with Rails 4.1 onwards. We don't need to build a custom scope, but instead can use our join association class instead.

Yes, scopes came in with Rails 4.0, but there's other differences in behaviour that makes removing the scope for 4.0 a pain in the neck.
Updating Polymorpher spec for ActiveRecord's new add_reflection.
Allow for a block with real-time callbacks instead of symbols indicating method path.

So, if you had a real-time index on Post, and you have a User model with many posts, and when a user is updated, you want the corresponding posts to update in Sphinx, you would have had the following:

    ThinkingSphinx::RealTime.callback_for(:post, [:posts])

But, if each post is loading other objects (say, a category), then the SQL behind this can get expensive quickly. Using a block instead of symbols allows you to be more flexible. A simple replacement:

    ThinkingSphinx::RealTime.callback_for(:post) { |user| user.posts }

Or, with preloading:

    ThinkingSphinx::RealTime.callback_for(:post) { |user| user.posts.include(:category) }

The array of method paths will still work, but only if the block is not provided (as it takes precedence). See #796.
Clearing up SphinxQL function/variable contexts.

This is required because Sphinx 2.0.x doesn't seem to like column aliases for special variable references (the aliases don't come through as the column names in search results). Frustrating, but there you go.
Models with more than one index now get fixed facet counts.

At least, with Sphinx 2.1.x onwards - can't use the count() function with Sphinx 2.0.x.
Adding status task.

Perhaps overkill, but it's a small enough bit of code that I'll let it in. Closes #795.
Log indexes that aren't processed due to guard files existing.

Closes #784.
Personal style of instance variables instead of self, limit accessor to reader.
Explicit source method.

I'm not entirely thrilled with the method_missing magic here anyway, but this is more to deal with Vlad injecting methods across pretty much every class (such a bad idea) as noted in #809.
field_weights and other search options now respected from set_property.