Commit b181575d authored by Magnus Westergaard's avatar Magnus Westergaard
Browse files

DEICH-5621: Consistent names.

parent 1f896aee
......@@ -101,14 +101,14 @@ func CreateSortBy(sortField string, sortOrder string) elastic.Sorter {
}
// escape reserved characters, but preserve any leading or trailing wildcards
func EscapeQueryStringQuery(q string) string {
func EscapeQueryStringQuery(query string) string {
wildcard := "*"
trimmedQ := strings.TrimSuffix(strings.TrimPrefix(q, wildcard), wildcard)
escapedQuery := reservedCharReplacer.Replace(trimmedQ)
if (strings.HasPrefix(q, wildcard)) {
trimmedQuery := strings.TrimSuffix(strings.TrimPrefix(query, wildcard), wildcard)
escapedQuery := reservedCharReplacer.Replace(trimmedQuery)
if (strings.HasPrefix(query, wildcard)) {
escapedQuery = fmt.Sprintf("%s%s", wildcard, escapedQuery)
}
if (strings.HasSuffix(q, wildcard)) {
if (strings.HasSuffix(query, wildcard)) {
escapedQuery = fmt.Sprintf("%s%s", escapedQuery, wildcard)
}
......
......@@ -349,9 +349,9 @@ func (pq parsedQuery) buildMustAndShouldQueries() (mustQueries, shouldQueries []
if len(pq.fieldTerms) > 0 {
var fields []string
for _, f := range pq.fieldTerms {
hasLeadingOrTrailingWildcard := strings.HasPrefix(f.term, "*") || strings.HasSuffix(f.term, "*")
leadingOrTrailingWildcard := strings.HasPrefix(f.term, "*") || strings.HasSuffix(f.term, "*")
escapedTerm := common.EscapeQueryStringQuery(f.term)
if hasLeadingOrTrailingWildcard || strings.Contains(f.term, " ") {
if leadingOrTrailingWildcard || strings.Contains(f.term, " ") {
fields = append(fields, fmt.Sprintf("%s:'%s'", f.field, escapedTerm))
} else {
fields = append(fields, fmt.Sprintf("%s:%s", f.field, escapedTerm))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment