Skip to content

Commit

Permalink
Merge pull request #65 from CDRH/query_quotations
Browse files Browse the repository at this point in the history
phrase searching enabled!
  • Loading branch information
techgique authored Oct 16, 2017
2 parents 3922578 + c35ca54 commit 94df989
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/services/search_item_req.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def build_request
return req
end

# TODO revisit this and determine if more needs to be done for text queries
def escape_chars(query)
# when string contains quotations marks, should end up passed to ES
# as \\" in order to phrase match
query.gsub('"', '\\\\\"')
end

def facets
# FACET_SORT
# unless specifically opting for "term", default to _count
Expand Down Expand Up @@ -256,12 +263,13 @@ def source
def text_search
must = {}
if @params["q"].present?
query = escape_chars(@params["q"])
# default to searching text field
# but can search _all field if necessary
must = {
"query_string" => {
"default_field" => "text",
"query" => @params["q"]
"query" => query
}
}
if @params["qfield"].present?
Expand Down

0 comments on commit 94df989

Please sign in to comment.