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