Class: PdfSearch::ElasticSearchQuery
- Inherits:
-
Object
- Object
- PdfSearch::ElasticSearchQuery
- Includes:
- Elasticsearch::DSL
- Defined in:
- lib/elastic_search_query.rb
Instance Attribute Summary collapse
-
#query_specification ⇒ Object
readonly
Returns the value of attribute query_specification.
-
#search_index ⇒ Object
readonly
Returns the value of attribute search_index.
Instance Method Summary collapse
-
#initialize(query_specification, search_index) ⇒ ElasticSearchQuery
constructor
A new instance of ElasticSearchQuery.
- #range_queries ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(query_specification, search_index) ⇒ ElasticSearchQuery
Returns a new instance of ElasticSearchQuery.
7 8 9 10 |
# File 'lib/elastic_search_query.rb', line 7 def initialize(query_specification, search_index) @search_index = search_index @query_specification = query_specification end |
Instance Attribute Details
#query_specification ⇒ Object (readonly)
Returns the value of attribute query_specification.
5 6 7 |
# File 'lib/elastic_search_query.rb', line 5 def query_specification @query_specification end |
#search_index ⇒ Object (readonly)
Returns the value of attribute search_index.
5 6 7 |
# File 'lib/elastic_search_query.rb', line 5 def search_index @search_index end |
Instance Method Details
#range_queries ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/elastic_search_query.rb', line 28 def range_queries search_index.search_input_fields_by_type[:interval].map do |name| { "range": { name => { gte: query_specification["search_#{name}_start"], lte: query_specification["search_#{name}_end"] } } } end end |
#to_hash ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/elastic_search_query.rb', line 12 def to_hash { "query": { "bool": { "must": [ { "match": { "text": query_specification['search'] } } ].concat(range_queries) } } } end |