Class: Qiita::Elasticsearch::FilterableToken
- Defined in:
- lib/qiita/elasticsearch/filterable_token.rb
Constant Summary collapse
- EDIT_PERMISSION_COEDITING =
2
Instance Attribute Summary
Attributes inherited from Token
Instance Method Summary collapse
- #to_hash ⇒ Hash
-
#type ⇒ String
Actual type name on Elasticsearch.
- #type? ⇒ Boolean
Methods inherited from Token
#downcased?, #downcased_term, #filter?, #initialize, #must?, #must_not?, #negative?, #or?, #positive?, #proper_cased_term, #query?, #quoted?, #sort?, #to_s
Constructor Details
This class inherits a constructor from Qiita::Elasticsearch::Token
Instance Method Details
#to_hash ⇒ Hash
9 10 11 12 13 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 |
# File 'lib/qiita/elasticsearch/filterable_token.rb', line 9 def to_hash case when archived? { "term" => { "archived" => true, }, } when code? { "query" => { "match_phrase" => { "code" => downcased_term, }, }, } when coediting? { "term" => { "edit_permission" => EDIT_PERMISSION_COEDITING, }, } when group? { "terms" => { "execution" => "or", "group_id" => group_ids, } } when type? { "type" => { "value" => type, }, } else { "term" => { @field_name => proper_cased_term, }, } end end |
#type ⇒ String
Returns actual type name on Elasticsearch.
54 55 56 57 58 59 60 |
# File 'lib/qiita/elasticsearch/filterable_token.rb', line 54 def type if article_type? "team_item" else term end end |
#type? ⇒ Boolean
Note:
Override
63 64 65 |
# File 'lib/qiita/elasticsearch/filterable_token.rb', line 63 def type? article_type? || project_type? end |