You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With a real-time index, I can provide a scope to filter out records I don't want indexed:
This allows eager loading of associations, or even filtering out specific values. However, keep in mind the default callbacks don’t use this scope, so a record that does not get included in this scope but is then altered will be added to your Sphinx data.
For real-time indices you can define a custom scope to preload associations or apply custom conditions:
scope { Article.includes(:comments) }
This scope only comes into play when populating all records at once, not when single records are created or updated.
So I need separate logic on update to filter out things I don't want indexed. Closest I can find is this info in callbacks...
If you wish to have your callbacks update Sphinx only in certain conditions, you can either define your own callback and then invoke TS if/when needed:
Or supply a block to the callback instantiation which returns an array of instances to process:
# if your model is app/models/article.rb:
ThinkingSphinx::Callbacks.append(self, :behaviours => [:real_time]) { |instance|
instance.indexing? ? [instance] : []
}
However this is changing what records are updated in Sphinx and not what records are in Sphinx. Specifically, if a record previously had indexing? return true, but now after an update returns false, the logic provided just means that no update will be sent to Sphinx (and it will remain in Sphinx), not that the record will be removed in Sphinx.
How do I remove a record from Sphinx on an update with a callback? Or am I thinking about this wrong?
The text was updated successfully, but these errors were encountered:
As per @akostadinov's great work, this should now be covered by ThinkingSphinx::Processor.new(instance: self).sync - it'll update records if they're still within the scope, or otherwise delete them.
With a real-time index, I can provide a
scope
to filter out records I don't want indexed:and
So I need separate logic on update to filter out things I don't want indexed. Closest I can find is this info in callbacks...
However this is changing what records are updated in Sphinx and not what records are in Sphinx. Specifically, if a record previously had
indexing?
returntrue
, but now after an update returnsfalse
, the logic provided just means that no update will be sent to Sphinx (and it will remain in Sphinx), not that the record will be removed in Sphinx.How do I remove a record from Sphinx on an update with a callback? Or am I thinking about this wrong?
The text was updated successfully, but these errors were encountered: