From a4d15bc641004af804ebe5d7548f9d6283369709 Mon Sep 17 00:00:00 2001 From: Anvit Srivastav Date: Thu, 22 Aug 2024 09:31:17 -0700 Subject: [PATCH] Add generateQuery method for arSolrPluginUtil Change the generateQueryString method in arSolrPluginUtil to create a solr query from the input string and rename the method to generateQuery. --- .../lib/arSolrPluginUtil.class.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/plugins/arSolrPlugin/lib/arSolrPluginUtil.class.php b/plugins/arSolrPlugin/lib/arSolrPluginUtil.class.php index ddd3b8fad5..84a135999f 100644 --- a/plugins/arSolrPlugin/lib/arSolrPluginUtil.class.php +++ b/plugins/arSolrPlugin/lib/arSolrPluginUtil.class.php @@ -173,27 +173,22 @@ public static function getI18nFieldNames($fields, $cultures = null) } /** - * Generate a query string query. + * Generate a solr query. * * @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 * - * @return \Elastica\Query\QueryString the generated query string query + * @return arSolrQuery the generated solr query */ - public static function generateQueryString( + public static function generateQuery( $query, $fields, $operator = 'AND' ) { - $queryString = new arSolrQueryString(self::escapeTerm($query)); - $queryString->setDefaultOperator($operator); - $queryString->setFields(self::getBoostedSearchFields($fields)); - $queryString->setAnalyzer( - arSolrMapping::getAnalyzer( - sfContext::getInstance()->user->getCulture() - ) - ); + $solrQuery = new arSolrQuery(self::escapeTerm($query)); + $solrQuery->setDefaultOperator($operator); + $solrQuery->setFields(self::getBoostedSearchFields($fields)); - return $queryString; + return $solrQuery; } public static function getBoostedSearchFields($fields)