Sha256: 61108c18587702b410cb51c35a3cef109c15051d683cb164cba1490c76de26a0
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
require "celsius/transformation/step" require "ox" class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchResultTransformation:: AddMissingFacets < Celsius::Transformation::Step # # Sometimes, requested facets do not show up in search result, so we have to (re)add them # def call (search_request["facets"] || {}).each do |facet_name, requested_facet| unless target["facets"][facet_name] if requested_facet["terms"] target["facets"][facet_name] = empty_search_result_terms_facet end end end end # private # def empty_search_result_terms_facet { "_type" => "terms", "terms" => [] } end =begin # handle primo bug where requested facets don't show up in search response process "//match", source: -> { @search_request} do |match, target| if (target_facet_name = match.nodes.first.value).start_with?("facet_") target_facet_value = match.nodes.first.text target_facet_count = find_all(@search_brief_return, "SEGMENTS/JAGROOT/RESULT/DOCSET/DOC").length # case 1 - there is no facet at all unless find(target, "facets/#{target_facet_name}") find(target, "facets") << element(target_facet_name) do |target_facet| target_facet << element("_type", text: "terms") target_facet << array("terms") end end # case 2 - there is a facet, but the requested facet is not included unless find_all(target, "facets/#{target_facet_name}/terms/terms/term").map(&:text).include?(target_facet_value) array(find(target, "facets/#{target_facet_name}/terms")) do |term| term << element("term", text: target_facet_value) term << element("count", text: target_facet_count.to_s, type: "integer") end end end end =end end
Version data entries
3 entries across 3 versions & 1 rubygems