Class: Qiita::Elasticsearch::Nodes::BoolQueryNode
- Inherits:
-
Object
- Object
- Qiita::Elasticsearch::Nodes::BoolQueryNode
- Defined in:
- lib/qiita/elasticsearch/nodes/bool_query_node.rb
Instance Method Summary collapse
-
#initialize(tokens, matchable_fields: nil) ⇒ BoolQueryNode
constructor
A new instance of BoolQueryNode.
- #to_hash ⇒ Object
Constructor Details
#initialize(tokens, matchable_fields: nil) ⇒ BoolQueryNode
Returns a new instance of BoolQueryNode.
9 10 11 12 |
# File 'lib/qiita/elasticsearch/nodes/bool_query_node.rb', line 9 def initialize(tokens, matchable_fields: nil) @matchable_fields = matchable_fields @tokens = tokens end |
Instance Method Details
#to_hash ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/qiita/elasticsearch/nodes/bool_query_node.rb', line 14 def to_hash case when has_only_one_should_token? should_query when has_only_one_must_token? must_query else { "bool" => { "must" => must_queries, "must_not" => must_not_queries, "should" => should_queries, }.reject do |key, value| value.empty? end, } end end |