Module: Insuggest::TpVendor::ClassMethods

Defined in:
lib/insuggest/tp_vendor.rb

Instance Method Summary collapse

Instance Method Details

#get_index_nameObject



15
16
17
# File 'lib/insuggest/tp_vendor.rb', line 15

def get_index_name
  "tp_vendors"
end

#repositoryObject



19
20
21
22
23
24
25
# File 'lib/insuggest/tp_vendor.rb', line 19

def repository
  index_name = get_index_name
  Elasticsearch::Persistence::Repository.new do
    index index_name
    type :tp_vendor
  end
end

#search(query = [], size = 100) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/insuggest/tp_vendor.rb', line 27

def search(query=[], size= 100)
  self.repository.search({
    size: size,
    query: {
      bool: {
        must: [
          { match: { category: query[0] } },
          { match: { sub_category: query[1] } },
        ]
      }
    }
  })[0]
end