Module: Insuggest::Gcv::Discount::ClassMethods
- Defined in:
- lib/insuggest/gcv/discount.rb
Instance Method Summary collapse
Instance Method Details
#get_index_name ⇒ Object
14 15 16 |
# File 'lib/insuggest/gcv/discount.rb', line 14 def get_index_name "gcv_discounts" end |
#repository ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/insuggest/gcv/discount.rb', line 18 def repository index_name = get_index_name Elasticsearch::Persistence::Repository.new do index index_name type :discount settings number_of_shards: 2 end end |
#search(age = 1, capacity = 0, size: 100) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/insuggest/gcv/discount.rb', line 27 def search(age=1, capacity=0, size: 100) self.repository.search({ size: size, query: { bool: { must: [ { range: {capacity_from: {lte: capacity}}}, { range: {capacity_to: {gte: capacity}}}, { range: {from: {lte: age}}}, { range: {to: {gte: age}}} ] } } }) end |