Sha256: a8a58364c2ba115c93c5b9f2cac0437e74432daa6ad3451b8448b7d317fab433

Contents?: true

Size: 769 Bytes

Versions: 5

Compression:

Stored size: 769 Bytes

Contents

require "celsius/transformation/step"
require "ox"

class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchResultTransformation::
  ProcessFacets < Celsius::Transformation::Step

  def call
    if source_facets = search_brief_return.locate("JAGROOT/RESULT/FACETLIST/FACET")
      source_facets.each do |source_facet|
        target["facets"]["facet_#{source_facet["NAME"]}"] = target_facet(source_facet)
      end
    end
  end

  #
  private
  #
  def target_facet(source_facet)
    {
      "_type" => "terms",
      "terms" => source_facet.locate("FACET_VALUES").map do |source_facet_value|
        {
          "term" => source_facet_value["KEY"].force_encoding("utf-8"),
          "count" => source_facet_value["VALUE"].to_i
        }
      end
    }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
celsius-primo-0.1.4 lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/process_facets.rb
celsius-primo-0.1.3 lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/process_facets.rb
celsius-primo-0.1.2 lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/process_facets.rb
celsius-primo-0.1.1 lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/process_facets.rb
celsius-primo-0.1.0 lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/process_facets.rb