Class: Qiita::Elasticsearch::Nodes::MatchQueryNode
- Inherits:
-
Object
- Object
- Qiita::Elasticsearch::Nodes::MatchQueryNode
- Defined in:
- lib/qiita/elasticsearch/nodes/match_query_node.rb
Instance Method Summary collapse
-
#initialize(token, matchable_fields: nil) ⇒ MatchQueryNode
constructor
A new instance of MatchQueryNode.
-
#to_hash ⇒ Hash
Match query or multi_match query.
Constructor Details
#initialize(token, matchable_fields: nil) ⇒ MatchQueryNode
7 8 9 10 |
# File 'lib/qiita/elasticsearch/nodes/match_query_node.rb', line 7 def initialize(token, matchable_fields: nil) @matchable_fields = matchable_fields @token = token end |
Instance Method Details
#to_hash ⇒ Hash
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/qiita/elasticsearch/nodes/match_query_node.rb', line 13 def to_hash if @matchable_fields.nil? { @token.quoted? ? "match_phrase" : "match" => { "_all" => @token.term, } } else hash = { "multi_match" => { "fields" => @matchable_fields, "query" => @token.term, }, } hash["multi_match"]["type"] = "phrase" if @token.quoted? hash end end |