class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::ProcessQueryStringQueries
Public Instance Methods
call()
click to toggle source
# File lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_query_string_queries.rb, line 7 def call if query_string_queries = Celsius::Hash.deep_find_key(source, :query_string) # memoize the QueryTerms node query_terms_node = transformation.inner_search_request.locate("PrimoSearchRequest/QueryTerms").first # if multiple queries strings are given, they all have to match query_terms_node.locate("BoolOpeator").first << "AND" # for each query_string query, add a QueryTerm node query_string_queries.each do |query_string_query| value = query_string_query[:query] || query_string_query["query"] # primo can only handle one (index_)field index_field = (query_string_query[:fields] || query_string_query["fields"]).first # translate the index field to a known primo index field index_field = index_field_mapping(index_field) query_terms_node << Ox.parse( <<-xml <QueryTerm> <IndexField>#{index_field}</IndexField> <PrecisionOperator>contains</PrecisionOperator> <Value>#{value}</Value> </QueryTerm> xml ) end end end