Method: Contentstack::Query#regex
- Defined in:
- lib/contentstack/query.rb
#regex(field_uid, pattern, options = "") ⇒ Contentstack::Query
Add a regular expression constraint for finding string values that match the provided regular expression. This may be slow for large data sets. Example:
@query = @stack.content_type('product').query
@query.regex('title', '.*Mobile.*', 'i') # Search without case sensitivity
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/contentstack/query.rb', line 85 def regex(field_uid, pattern, ="") hash = { "#{field_uid}" => { "$regex": pattern } } hash["#{field_uid}"]["$options"] = if !.empty? || !.nil? add_query_hash(hash) end |