Class: WinewooCore::Services::ElasticSearch::WinesServices
- Inherits:
-
Object
- Object
- WinewooCore::Services::ElasticSearch::WinesServices
- Defined in:
- lib/winewoo_core/services/elastic_search/wines_services.rb
Instance Method Summary collapse
- #fetch_wines(keywords, page, per_page) ⇒ Object
-
#initialize ⇒ WinesServices
constructor
A new instance of WinesServices.
Constructor Details
#initialize ⇒ WinesServices
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 |