Module: Insuggest::Depreciation::ClassMethods
- Defined in:
- lib/insuggest/depreciation.rb
Instance Method Summary collapse
- #get_index_name ⇒ Object
- #repository ⇒ Object
- #search(query = [], size = 100, age = 1, percent) ⇒ Object
Instance Method Details
#get_index_name ⇒ Object
15 16 17 |
# File 'lib/insuggest/depreciation.rb', line 15 def get_index_name "depreciations" end |
#repository ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/insuggest/depreciation.rb', line 19 def repository index_name = get_index_name Elasticsearch::Persistence::Repository.new do index index_name type :depreciation settings number_of_shards: 4 do mapping do indexes :suggest_make, type: 'completion', payloads: true, index_analyzer: "simple", search_analyzer: "simple" indexes :suggest_model, type: 'completion', payloads: true, index_analyzer: "simple", search_analyzer: "simple" end end end end |
#search(query = [], size = 100, age = 1, percent) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/insuggest/depreciation.rb', line 39 def search(query=[], size= 100, age=1, percent) self.repository.search({ size: size, query: { bool: { must: [ { match: { make: { query: query[0], minimum_should_match: percent[0] } } }, { match: { model: { query: query[1], minimum_should_match: percent[1] } } }, { match: { submodel: { query: query[2], minimum_should_match: percent[2] } } } ] } } }) end |