Class: Qiita::Elasticsearch::Nodes::FilterQueryNode
- Inherits:
-
Object
- Object
- Qiita::Elasticsearch::Nodes::FilterQueryNode
- Defined in:
- lib/qiita/elasticsearch/nodes/filter_query_node.rb
Constant Summary collapse
- DEFAULT_HIERARCHAL_FIELDS =
[]
Instance Method Summary collapse
-
#initialize(token, hierarchal_fields: nil) ⇒ FilterQueryNode
constructor
A new instance of FilterQueryNode.
- #to_hash ⇒ Hash
Constructor Details
#initialize(token, hierarchal_fields: nil) ⇒ FilterQueryNode
8 9 10 11 |
# File 'lib/qiita/elasticsearch/nodes/filter_query_node.rb', line 8 def initialize(token, hierarchal_fields: nil) @hierarchal_fields = hierarchal_fields @token = token end |
Instance Method Details
#to_hash ⇒ Hash
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/qiita/elasticsearch/nodes/filter_query_node.rb', line 14 def to_hash if has_hierarchal_token? { "filtered" => { "filter" => { "bool" => { "should" => [ { "prefix" => { @token.field_name => @token.term + "/", }, }, { "term" => { @token.field_name => @token.term, }, }, ], }, }, "query" => { "match_all" => {}, }, }, } else { "filtered" => { "filter" => { "term" => { @token.field_name => @token.term, }, }, "query" => { "match_all" => {}, }, }, } end end |