Class: Qiita::Elasticsearch::Nodes::QueryNode
- Inherits:
-
Object
- Object
- Qiita::Elasticsearch::Nodes::QueryNode
- Defined in:
- lib/qiita/elasticsearch/nodes/query_node.rb
Instance Method Summary collapse
-
#initialize(tokens, hierarchal_fields: nil, matchable_fields: nil) ⇒ QueryNode
constructor
A new instance of QueryNode.
- #to_hash ⇒ Object
Constructor Details
#initialize(tokens, hierarchal_fields: nil, matchable_fields: nil) ⇒ QueryNode
Returns a new instance of QueryNode.
10 11 12 13 14 |
# File 'lib/qiita/elasticsearch/nodes/query_node.rb', line 10 def initialize(tokens, hierarchal_fields: nil, matchable_fields: nil) @hierarchal_fields = hierarchal_fields @matchable_fields = matchable_fields @tokens = tokens end |
Instance Method Details
#to_hash ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/qiita/elasticsearch/nodes/query_node.rb', line 16 def to_hash case @tokens.length when 0 {} when 1 MatchNode.new( @tokens.first, matchable_fields: @matchable_fields, ).to_hash else MultiShouldNode.new( @tokens, matchable_fields: @matchable_fields, ).to_hash end end |