Skip to content

Commit

Permalink
Rename arSolrQuery to arSolrStringQuery
Browse files Browse the repository at this point in the history
Change arSolrQuery to arSolrStringQuery to avoid confusion with
Elastica's Query
  • Loading branch information
anvit committed Aug 26, 2024
1 parent d3dc40d commit 91e3d3a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/task/search/arSolrSearchTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function configure()

private function createQuery($queryText, $fields)
{
$query = new arSolrQuery(arSolrPluginUtil::escapeTerm($queryText));
$query = new arSolrStringQuery(arSolrPluginUtil::escapeTerm($queryText));
if ($fields) {
$fieldsArr = explode(',', $fields);
$newFields = [];
Expand Down
4 changes: 2 additions & 2 deletions plugins/arSolrPlugin/lib/arSolrPluginUtil.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ public static function getI18nFieldNames($fields, $cultures = null)
* @param array $fields fields to search (including culture if needed)
* @param string $operator default query operator (AND/OR), default: AND
*
* @return arSolrQuery the generated solr query
* @return arSolrStringQuery the generated solr query
*/
public static function generateQuery(
$query, $fields, $operator = 'AND'
) {
$solrQuery = new arSolrQuery(self::escapeTerm($query));
$solrQuery = new arSolrStringQuery(self::escapeTerm($query));
$solrQuery->setDefaultOperator($operator);
$solrQuery->setFields(self::getBoostedSearchFields($fields));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

/**
* arSolrQuery.
* arSolrStringQuery.
*/
class arSolrQuery extends arSolrAbstractQuery
class arSolrStringQuery extends arSolrAbstractQuery
{
/**
* Query Params.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

use PHPUnit\Framework\TestCase;

require_once 'plugins/arSolrPlugin/lib/query/arSolrQuery.class.php';
require_once 'plugins/arSolrPlugin/lib/query/arSolrStringQuery.class.php';

/**
* @internal
*
* @covers \arSolrQuery
* @covers \arSolrStringQuery
*/
class ArSolrQueryTest extends TestCase
{
public function createSolrQueryProvider()
{
return [
'New arSolrQuery with default options' => [
'New arSolrStringQuery with default options' => [
'searchQuery' => '*:*',
'expected' => '*:*',
],
Expand All @@ -29,16 +29,16 @@ public function createSolrQueryProvider()
*/
public function testCreateSolrQuery($searchQuery, $expected)
{
$this->query = new arSolrQuery($searchQuery);
$this->query = new arSolrStringQuery($searchQuery);
$actual = $this->query->getSearchQuery();

$this->assertTrue($this->query instanceof arSolrQuery, 'Assert plugin object is arSolrQuery.');
$this->assertSame($expected, $actual, 'Assert arSolrQuery search query is correct.');
$this->assertTrue($this->query instanceof arSolrStringQuery, 'Assert plugin object is arSolrStringQuery.');
$this->assertSame($expected, $actual, 'Assert arSolrStringQuery search query is correct.');
}

public function testSetFields()
{
$this->query = new arSolrQuery('*:*');
$this->query = new arSolrStringQuery('*:*');

// Test setting the fields to empty array
$this->query->setFields('');
Expand Down Expand Up @@ -76,7 +76,7 @@ public function setDefaultOperatorProvider()
*/
public function testSetDefaultOperator($operator, $expected)
{
$this->query = new arSolrQuery('*:*');
$this->query = new arSolrStringQuery('*:*');
$this->query->setDefaultOperator($operator);
$actual = $this->query->getDefaultOperator();

Expand All @@ -85,7 +85,7 @@ public function testSetDefaultOperator($operator, $expected)

public function testSetDefaultOperatorException()
{
$this->query = new arSolrQuery('*:*');
$this->query = new arSolrStringQuery('*:*');

$this->expectException('\Exception');
$this->expectExceptionMessage('Invalid operator. AND and OR are the only acceptable operator types.');
Expand All @@ -95,7 +95,7 @@ public function testSetDefaultOperatorException()

public function testSetAggregations()
{
$this->query = new arSolrQuery('*:*');
$this->query = new arSolrStringQuery('*:*');

// Test setting the aggrergations to empty array
$this->query->setAggregations([]);
Expand Down Expand Up @@ -144,7 +144,7 @@ public function getQueryParamsProvider(): array
*/
public function testGetQueryParams($fields, $type, $operator, $searchQuery, $expected)
{
$this->query = new arSolrQuery($searchQuery);
$this->query = new arSolrStringQuery($searchQuery);
$this->query->setFields($fields);
$this->query->setDefaultOperator($operator);
$this->query->setType($type);
Expand Down Expand Up @@ -201,7 +201,7 @@ public function getQueryParamsAggsProvider(): array
*/
public function testGetQueryParamsAggs($fields, $operator, $type, $searchQuery, $aggregations, $expected)
{
$this->query = new arSolrQuery($searchQuery);
$this->query = new arSolrStringQuery($searchQuery);
$this->query->setFields($fields);
$this->query->setType($type);
$this->query->setDefaultOperator($operator);
Expand Down Expand Up @@ -240,7 +240,7 @@ public function getQueryParamsAggsExceptionProvider(): array
*/
public function testGetQueryParamsAggsException($fields, $type, $expectedException, $expectedExceptionMessage)
{
$this->query = new arSolrQuery('*:*');
$this->query = new arSolrStringQuery('*:*');
$this->query->setFields($fields);
$this->query->setType($type);

Expand Down

0 comments on commit 91e3d3a

Please sign in to comment.