Skip to content

Commit

Permalink
Fix search query special chars (#1605)
Browse files Browse the repository at this point in the history
The search query used in the generateQueryString function does not
escape special characters specified in the escape_queries setting, and
the query provided to it by arElasticSearchPluginQuery has not been
previously escaped either. Updating this to call escapeTerm to escape
the search query so that this setting is respected.
  • Loading branch information
anvit committed Oct 3, 2023
1 parent 60c961c commit f374ec5
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static function getI18nFieldNames($fields, $cultures = null)
/**
* Generate a query string query.
*
* @param string $query escaped search term
* @param string $query unescaped search term
* @param array $fields fields to search (including culture if needed)
* @param string $operator default query operator (AND/OR), default: AND
*
Expand All @@ -180,7 +180,7 @@ public static function getI18nFieldNames($fields, $cultures = null)
public static function generateQueryString(
$query, $fields, $operator = 'AND'
) {
$queryString = new \Elastica\Query\QueryString($query);
$queryString = new \Elastica\Query\QueryString(self::escapeTerm($query));
$queryString->setDefaultOperator($operator);
$queryString->setFields(self::getBoostedSearchFields($fields));
$queryString->setAnalyzer(
Expand Down

0 comments on commit f374ec5

Please sign in to comment.