Class: Relaton::Bsi::HitCollection
- Inherits:
-
Core::HitCollection
- Object
- Core::HitCollection
- Relaton::Bsi::HitCollection
- Defined in:
- lib/relaton/bsi/hit_collection.rb
Overview
Page of hit collection.
Constant Summary collapse
- DOMAIN =
"https://shop.bsigroup.com"
Class Method Summary collapse
-
.search(ref, year = nil) ⇒ Relaton::Bsi::HitCollection
Initialize a new HitCollection object and perform search.
Instance Method Summary collapse
-
#algolia_index ⇒ Algolia::Search::Index
Algolia index.
-
#filter_hits!(code_parts) ⇒ self
Filter the search results for a BSI standard.
-
#search ⇒ self
Perform search.
Class Method Details
.search(ref, year = nil) ⇒ Relaton::Bsi::HitCollection
Initialize a new HitCollection object and perform search.
19 20 21 |
# File 'lib/relaton/bsi/hit_collection.rb', line 19 def self.search(ref, year = nil) new(ref, year).search end |
Instance Method Details
#algolia_index ⇒ Algolia::Search::Index
Algolia index.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/relaton/bsi/hit_collection.rb', line 38 def algolia_index @algolia_index ||= begin config = Algolia::Search::Config.new( application_id: "575YE157G9", api_key: "a057b4e74099445df2eddb7940828a10", ) client = Algolia::Search::Client.new config, logger: ::Logger.new($stderr) client.init_index "shopify_products" end end |
#filter_hits!(code_parts) ⇒ self
Filter the search results for a BSI standard.
56 57 58 59 60 61 62 |
# File 'lib/relaton/bsi/hit_collection.rb', line 56 def filter_hits!(code_parts) hits = filter code_parts hits = filter code_parts, skip_rest: true if hits.empty? hits = filter code_parts, drop_amd: true if hits.empty? @array = hits self end |
#search ⇒ self
Perform search.
26 27 28 29 30 |
# File 'lib/relaton/bsi/hit_collection.rb', line 26 def search resp = algolia_index.search ref # , facetFilters: "product_type:standard" @array = create_hits resp[:hits] self end |