Skip to end of metadata
Go to start of metadata

percolate(<js_function>)

The percolate action iterates through search results on the current page as well as pages after the current page. Currently the percolate action takes a javascript function as its parameter. This function is run for each search result with the result being passed in as a parameter. A search result is percolated, or brought to the top, when the function passed to the action returns true. To start off, lets take a simple example and explain it:

Now let's break this simple percolation example down: the first part of the rule,

select using "google.com|search.yahoo.com|bing.com" setting()

tells the rule what domains to fire on, in this particular select statement, we use the regex OR symbol "|" to tell this rule to fire on any of the sites in the statement.

The next part of the rule takes place in an

emit << >>

block. This allows us to code Javascript directly into our rule.

Inside of our emit block, we code a function that defines how search resultes are percolated, this is the beauty of the percolate action, you write our own function that fully customizes the way that the search percolation happens. The percolate action simply takes your custom function as a parameter.

In the above specific percolation example, we just implement a simple domain check. First note that your percolation function takes a parameter, and then that parameter is used to pull information using the .data() method. The .data() method only works like this when your percolation function is used with the KRL action, percolate. In this example, we check the domain of the current search result, and if it matches "kynetx.com", we return true, which tells the percolate action to percolate it.

There are infinitely many ways one can design their custom percolate function, one way is to run through a JSON object, and if the key is found, percolate it.

The following ruleset shows percolate() being used

 

 

Labels: