Class: AtlasEngine::CountryRepository
- Inherits:
-
Object
- Object
- AtlasEngine::CountryRepository
- Extended by:
- T::Sig
- Includes:
- LogHelper
- Defined in:
- app/models/atlas_engine/country_repository.rb
Constant Summary collapse
- PostAddressData =
T.type_alias { T.any(PostAddress, T::Hash[Symbol, T.untyped]) }
Instance Method Summary collapse
- #analyze(query) ⇒ Object
- #find(id) ⇒ Object
-
#initialize(country_code:, repository_class:, locale: nil, index_configuration: nil) ⇒ CountryRepository
constructor
A new instance of CountryRepository.
- #search(query) ⇒ Object
- #term_vectors(query) ⇒ Object
Methods included from LogHelper
#log_error, #log_info, #log_warn
Constructor Details
#initialize(country_code:, repository_class:, locale: nil, index_configuration: nil) ⇒ CountryRepository
Returns a new instance of CountryRepository.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/atlas_engine/country_repository.rb', line 29 def initialize(country_code:, repository_class:, locale: nil, index_configuration: nil) @country_code = T.let(country_code.to_s.downcase, String) @country_profile = T.let(CountryProfile.for(@country_code, locale), CountryProfile) @repository = T.let( repository_class.new( index_base_name: index_name(country_code: @country_code, locale: locale), index_mappings: index_configuration.present? ? index_configuration["mappings"] : {}, index_settings: index_configuration.present? ? index_configuration["settings"] : {}, mapper_callable: mapper_callable, ), Elasticsearch::RepositoryInterface, ) end |
Instance Method Details
#analyze(query) ⇒ Object
55 56 57 |
# File 'app/models/atlas_engine/country_repository.rb', line 55 def analyze(query) build_analyze_result(repository.analyze(query)) end |
#find(id) ⇒ Object
45 46 47 |
# File 'app/models/atlas_engine/country_repository.rb', line 45 def find(id) repository.find(id).deep_stringify_keys end |
#search(query) ⇒ Object
50 51 52 |
# File 'app/models/atlas_engine/country_repository.rb', line 50 def search(query) repository.search(query)["hits"]["hits"] end |
#term_vectors(query) ⇒ Object
60 61 62 |
# File 'app/models/atlas_engine/country_repository.rb', line 60 def term_vectors(query) build_term_vectors(repository.term_vectors(query)) end |