Class: Redis::Commands::Search::NumericField
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Field
|
|
|
Instance Chain:
self,
Field
|
|
| Inherits: |
Redis::Commands::Search::Field
|
| Defined in: | lib/redis/commands/modules/search/field.rb |
Overview
A NUMERIC field, indexing numeric values for range queries.
Class Method Summary
-
.new(name, query = nil, **options) ⇒ NumericField
constructor
Build a
NUMERICfield.
Field - Inherited
| .new | Build a field definition. |
Instance Attribute Summary
Instance Method Summary
-
#between(min, max) ⇒ Query
Add an inclusive range predicate to the bound query.
-
#gt(value) ⇒ Query
Add a greater-than range predicate to the bound query.
-
#lt(value) ⇒ Query
Add a less-than range predicate to the bound query.
Field - Inherited
| #to_args | Render this field as the array of |
Constructor Details
.new(name, query = nil, **options) ⇒ NumericField
Build a NUMERIC field.
# File 'lib/redis/commands/modules/search/field.rb', line 144
def initialize(name, query = nil, **) super(name, :numeric, query, **) end
Instance Method Details
#between(min, max) ⇒ Query
Add an inclusive range predicate to the bound query.
# File 'lib/redis/commands/modules/search/field.rb', line 172
def between(min, max) # Coerce to numeric so a value can't inject range/query syntax. RangePredicate renders # bounds verbatim, so the field boundary is where untrusted input must be validated. query.add_predicate(RangePredicate.new(@alias_name || name, Float(min), Float(max))) end
#gt(value) ⇒ Query
Add a greater-than range predicate to the bound query.
# File 'lib/redis/commands/modules/search/field.rb', line 153
def gt(value) query.add_predicate(RangePredicate.new(@alias_name || name, "(#{Float(value)}", "+inf")) end
#lt(value) ⇒ Query
Add a less-than range predicate to the bound query.
# File 'lib/redis/commands/modules/search/field.rb', line 162
def lt(value) query.add_predicate(RangePredicate.new(@alias_name || name, "-inf", "(#{Float(value)}")) end