Class: Parse::Constraint::FullTextSearchQueryConstraint
- Inherits:
-
Parse::Constraint
- Object
- Parse::Constraint
- Parse::Constraint::FullTextSearchQueryConstraint
- Defined in:
- lib/parse/query/constraints.rb
Instance Attribute Summary
Attributes inherited from Parse::Constraint
#operand, #operation, #operator, #value
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint.
-
#text_search ⇒ WithinPolygonQueryConstraint
A registered method on a symbol to create the constraint.
Methods inherited from Parse::Constraint
#as_json, contraint_keyword, create, formatted_value, #formatted_value, #initialize, #key, #precedence, register, #to_s
Constructor Details
This class inherits a constructor from Parse::Constraint
Instance Method Details
#build ⇒ Hash
Returns the compiled constraint.
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
# File 'lib/parse/query/constraints.rb', line 740 def build params = formatted_value params = { :$term => params.to_s } if params.is_a?(String) || params.is_a?(Symbol) unless params.is_a?(Hash) raise ArgumentError, '[Parse::Query] Invalid query value parameter passed to'\ ' `text_search` constraint: Value must be a string or a hash of parameters.' end params = params.inject({}) do |h,(k,v)| u = k.to_s u = u.columnize.prepend('$') unless u.start_with?('$') h[u] = v h end unless params["$term"].present? raise ArgumentError, "[Parse::Query] Invalid query value parameter passed to"\ " `text_search` constraint: Missing required `$term` subkey.\n"\ "\tExample: #{@operation.operand}.text_search => { term: 'text to search' }" end { @operation.operand => { :$text => { :$search => params } } } end |
#text_search ⇒ WithinPolygonQueryConstraint
Note:
This method will automatically add ‘$` to each key of the parameters
A registered method on a symbol to create the constraint. Maps to Parse operator “$text” with “$search” subconstraint. Takes a hash of parameters. Where ‘parameters` can be one of:
$term : Specify a field to search (Required)
$language : Determines the list of stop words and the rules for tokenizer.
$caseSensitive : Enable or disable case sensitive search.
$diacriticSensitive : Enable or disable diacritic sensitive search
hash if it doesn’t already have it.
736 |
# File 'lib/parse/query/constraints.rb', line 736 contraint_keyword :$text |