by Ben Ubois
Percolate allows you to register queries ahead of time, then whenever you send a new document to be indexed, elasticsearch can tell you if this document matches any saved queries.
Here’s how it works.
Feedbin is a Rails app and uses the tire gem for working with elasticsearch.
Whenever an action is added or updated, it is also sent to elasticsearch as a percolator query.
3 is the id of this action. This is used later on to find what user this action belongs to and which actions should be performed.
A model called
Entry is used for storing RSS articles. Whenever a new entry is added it also gets sent to elasticsearch for indexing.
An array of matched actions ids is returned in
result['matches']. So if this entry mentions “kittens” an array like
["3"] would be returned.
Feedbin uses Sidekiq to process background jobs. The
ActionsPerform.perform_async part is creating a new background job that performs the actions. A simplified version of this looks like: