Skip to content

Commit

Permalink
Add generateQuery method for arSolrPluginUtil
Browse files Browse the repository at this point in the history
Change the generateQueryString method in arSolrPluginUtil to create a
solr query from the input string and rename the method to generateQuery.
  • Loading branch information
anvit committed Aug 22, 2024
1 parent aabd964 commit a4d15bc
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions plugins/arSolrPlugin/lib/arSolrPluginUtil.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a4d15bc

Please sign in to comment.