Method: SearchFlip::Filterable#range

Defined in:
lib/search_flip/filterable.rb

#range(field, options = {}) ⇒ SearchFlip::Criteria

Adds a range filter to the criteria without being forced to specify the left and right end of the range, such that you can eg simply specify lt, lte, gt and gte. For fully specified ranges, you can as well use #where, etc. Check out the Elasticsearch docs for further details regarding the range filter.

Examples:

CommentIndex.range(:created_at, gte: Time.parse("2016-01-01"))
CommentIndex.range(:likes_count, gt: 10, lt: 100)

Parameters:

  • field (Symbol, String)

    The field name to specify the range for

  • options (Hash) (defaults to: {})

    The range filter specification, like lt, lte, etc

Returns:



206
207
208
# File 'lib/search_flip/filterable.rb', line 206

def range(field, options = {})
  filter(range: { field => options })
end