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) ⇒ OrSeparatableNode
constructor
A new instance of OrSeparatableNode.
- #to_hash ⇒ Object
Constructor Details
#initialize(tokens) ⇒ OrSeparatableNode
9 10 11 |
# File 'lib/qiita/elasticsearch/nodes/or_separatable_node.rb', line 9 def initialize(tokens) @tokens = tokens end |
Instance Method Details
#to_hash ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/qiita/elasticsearch/nodes/or_separatable_node.rb', line 13 def to_hash case tokens_grouped_by_or_token.size when 0 Nodes::AnyNode.new.to_hash when 1 Nodes::FilterableNode.new(tokens_grouped_by_or_token.first).to_hash else { "bool" => { "should" => tokens_grouped_by_or_token.map do |tokens| Nodes::FilterableNode.new(tokens).to_hash end, }, } end end |