Class: Qiita::Elasticsearch::Nodes::OrSeparatableNode
- Inherits:
-
Object
- Object
- Qiita::Elasticsearch::Nodes::OrSeparatableNode
- Defined in:
- lib/qiita/elasticsearch/nodes/or_separatable_node.rb
Instance Method Summary collapse
-
#initialize(tokens, hierarchal_fields: nil, matchable_fields: nil) ⇒ OrSeparatableNode
constructor
A new instance of OrSeparatableNode.
- #to_hash ⇒ Object
Constructor Details
#initialize(tokens, hierarchal_fields: nil, matchable_fields: nil) ⇒ OrSeparatableNode
Returns a new instance of OrSeparatableNode.
11 12 13 14 15 |
# File 'lib/qiita/elasticsearch/nodes/or_separatable_node.rb', line 11 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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/qiita/elasticsearch/nodes/or_separatable_node.rb', line 17 def to_hash case tokens_grouped_by_or_token.size when 0 Nodes::NullNode.new.to_hash when 1 Nodes::FilterableNode.new( tokens_grouped_by_or_token.first, hierarchal_fields: @hierarchal_fields, matchable_fields: @matchable_fields, ).to_hash else { "bool" => { "should" => tokens_grouped_by_or_token.map do |tokens| Nodes::FilterableNode.new( tokens, hierarchal_fields: @hierarchal_fields, matchable_fields: @matchable_fields, ).to_hash end, }, } end end |