Class: WinewooCore::Services::ElasticSearch::WinesServices

Inherits:
Object
  • Object
show all
Defined in:
lib/winewoo_core/services/elastic_search/wines_services.rb

Instance Method Summary collapse

Constructor Details

#initializeWinesServices

Returns a new instance of WinesServices.



6
7
8
# File 'lib/winewoo_core/services/elastic_search/wines_services.rb', line 6

def initialize
  @client = Elasticsearch::Client.new host: 'reco.kasual.biz:9200'
end

Instance Method Details

#fetch_wines(keywords, page, per_page) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/winewoo_core/services/elastic_search/wines_services.rb', line 11

def fetch_wines(keywords, page, per_page)
  from = page * per_page
  size = per_page
  raw = @client.search index: "wines",
    body: request_body(keywords, from, size)

  Rails.logger.info "WINEWOO RAW #{raw}"

  Parsers::WinesParser.parse(raw["hits"]["hits"])
end