diff --git a/lib/Connectors/BaseConnector.php b/lib/Connectors/BaseConnector.php index 079c6859..0f697301 100644 --- a/lib/Connectors/BaseConnector.php +++ b/lib/Connectors/BaseConnector.php @@ -23,18 +23,14 @@ use Elastica\Client; use Elastica\Index; -use Elastica\Mapping; use Elastica\Request; -use Elastica\Search; -use Elastica\Document; -use Elastica\Bulk; -use Elastica\Query; use Elastica\Result; use Elastica\ResultSet; use OC\Files\Cache\Cache; use OC\Files\Filesystem; use OC\Files\View; use OCA\Search_Elastic\SearchElasticConfigService; +use OCA\Search_Elastic\Connectors\ElasticaFactory; use OC\Share\Constants; use OCP\Files\Node; use OCP\Files\Folder; @@ -61,6 +57,8 @@ abstract class BaseConnector implements IConnector { /** @var Client */ private $client; + /** @var ElasticaFactory */ + private $factory; /** @var SearchElasticConfigService */ private $esConfig; /** @var IGroupManager */ @@ -78,12 +76,14 @@ abstract class BaseConnector implements IConnector { */ public function __construct( Client $client, + ElasticaFactory $factory, SearchElasticConfigService $esConfig, IGroupManager $groupManager, IUserManager $userManager, ILogger $logger ) { $this->client = $client; + $this->factory = $factory; $this->esConfig = $esConfig; $this->groupManager = $groupManager; $this->userManager = $userManager; @@ -97,7 +97,7 @@ public function __construct( */ final protected function getIndex() { if (!isset($this->index)) { - $this->index = new Index($this->client, $this->getIndexName()); + $this->index = $this->factory->getNewIndex($this->client, $this->getIndexName()); } return $this->index; } @@ -210,7 +210,7 @@ final public function prepareIndex() { $mappingData = $this->getMappingPropertiesConf(); if (!empty($mappingData)) { - $mapping = new Mapping(); + $mapping = $this->factory->getNewMapping(); $mapping->setProperties($mappingData); $mapping->send($index); } @@ -260,7 +260,7 @@ final public function indexNode(string $userId, Node $node, bool $extractContent $access = $this->getUsersWithReadPermission($node, $userId); $extractedData = $this->extractNodeData($node, $access); - $doc = new Document((string)$node->getId()); + $doc = $this->factory->getNewDocument((string)$node->getId()); foreach ($extractedData as $key => $value) { $doc->set($key, $value); } @@ -279,7 +279,7 @@ final public function indexNode(string $userId, Node $node, bool $extractContent // this is a workaround to acutally be able to use parameters when setting a document // see: https://github.com/ruflin/Elastica/issues/1248 - $bulk = new Bulk($index->getClient()); + $bulk = $this->factory->getNewBulk($index->getClient()); $bulk->setIndex($index); $bulk->setRequestParam('pipeline', $this->getProcessorName()); $bulk->addDocuments([$doc]); @@ -423,10 +423,10 @@ final public function fetchResults(string $userId, string $query, int $limit, in $proposedEsQuery = $this->getElasticSearchQuery($query, $opts); $this->logger->info('query: ' . json_encode($proposedEsQuery), ['search_elastic']); // TODO: Reduce log level to debug - $es_query = new Query(); + $es_query = $this->factory->getNewQuery(); $es_query->setRawQuery($proposedEsQuery); - $search = new Search($this->client); + $search = $this->factory->getNewSearch($this->client); $search->addIndex($this->getIndex()); return $search->search($es_query); } diff --git a/lib/Connectors/ConnectorLegacy.php b/lib/Connectors/ConnectorLegacy.php index 1e9c9bdb..8f013973 100644 --- a/lib/Connectors/ConnectorLegacy.php +++ b/lib/Connectors/ConnectorLegacy.php @@ -23,6 +23,7 @@ use Elastica\Client; use OCA\Search_Elastic\SearchElasticConfigService; +use OCA\Search_Elastic\Connectors\ElasticaFactory; use OCP\Files\Node; use OCP\IGroupManager; use OCP\IUserManager; @@ -31,12 +32,13 @@ class ConnectorLegacy extends BaseConnector { public function __construct( Client $client, + ElasticaFactory $factory, SearchElasticConfigService $esConfig, IGroupManager $groupManager, IUserManager $userManager, ILogger $logger ) { - parent::__construct($client, $esConfig, $groupManager, $userManager, $logger); + parent::__construct($client, $factory, $esConfig, $groupManager, $userManager, $logger); } /** @@ -54,8 +56,8 @@ protected function extractNodeData(Node $node, array $access): array { } protected function getElasticSearchQuery(string $query, array $opts): array { - $users = \implode(' OR ', $opts['access']['users']); - $groups = \implode(' OR ', $opts['access']['groups']); + $users = $opts['access']['users'] ?? []; + $groups = $opts['access']['groups'] ?? []; $size = $opts['size'] ?? 30; $from = $opts['from'] ?? 0; @@ -66,16 +68,8 @@ protected function getElasticSearchQuery(string $query, array $opts): array { [ 'bool' => [ 'should' => [ - [ - 'match' => [ - 'users' => $users, - ] - ], - [ - 'match' => [ - 'groups' => $groups, - ], - ], + // assume there will be matches to be included here + // coming from users and groups ], ], ], @@ -101,6 +95,13 @@ protected function getElasticSearchQuery(string $query, array $opts): array { 'from' => $from, ]; + foreach ($users as $user) { + $es_query['query']['bool']['filter'][0]['bool']['should'][] = ['match' => ['users' => $user]]; + } + foreach ($groups as $group) { + $es_query['query']['bool']['filter'][0]['bool']['should'][] = ['match' => ['groups' => $group]]; + } + if ($opts['searchContent']) { $es_query['query']['bool']['should'][] = [ 'query_string' => [ diff --git a/lib/Connectors/ConnectorRelevanceV2.php b/lib/Connectors/ConnectorRelevanceV2.php index 37d4a209..c74fb6c6 100644 --- a/lib/Connectors/ConnectorRelevanceV2.php +++ b/lib/Connectors/ConnectorRelevanceV2.php @@ -24,6 +24,7 @@ use Elastica\Client; use Elastica\Result; use OCA\Search_Elastic\SearchElasticConfigService; +use OCA\Search_Elastic\Connectors\ElasticaFactory; use OCP\Files\Node; use OCP\Files\FileInfo; use OCP\IGroupManager; @@ -33,12 +34,13 @@ class ConnectorRelevanceV2 extends BaseConnector { public function __construct( Client $client, + ElasticaFactory $factory, SearchElasticConfigService $esConfig, IGroupManager $groupManager, IUserManager $userManager, ILogger $logger ) { - parent::__construct($client, $esConfig, $groupManager, $userManager, $logger); + parent::__construct($client, $factory, $esConfig, $groupManager, $userManager, $logger); } protected function getIndexSettingsConf(): array { @@ -199,8 +201,8 @@ protected function extractNodeData(Node $node, array $access): array { } protected function getElasticSearchQuery(string $query, array $opts): array { - $users = \implode(' OR ', $opts['access']['users']); - $groups = \implode(' OR ', $opts['access']['groups']); + $users = $opts['access']['users'] ?? []; + $groups = $opts['access']['groups'] ?? []; $size = $opts['size'] ?? 30; $from = $opts['from'] ?? 0; @@ -267,12 +269,12 @@ protected function getElasticSearchQuery(string $query, array $opts): array { 'bool' => [ 'should' => [ [ - 'match' => [ + 'terms' => [ 'users' => $users, ] ], [ - 'match' => [ + 'terms' => [ 'groups' => $groups, ], ], diff --git a/lib/Connectors/ElasticaFactory.php b/lib/Connectors/ElasticaFactory.php new file mode 100644 index 00000000..a2232c52 --- /dev/null +++ b/lib/Connectors/ElasticaFactory.php @@ -0,0 +1,61 @@ + + * + * @copyright Copyright (c) 2019, ownCloud GmbH + * @license GPL-2.0 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +namespace OCA\Search_Elastic\Tests\Unit\Connectors; + +use Elastica\Client; +use Elastica\Index; +use Elastica\Request; +use Elastica\Response; +use Elastica\Query; +use Elastica\Search; +use Elastica\Result; +use Elastica\Index\Stats; +use OCA\Search_Elastic\SearchElasticConfigService; +use OCP\IGroupManager; +use OCP\IUserManager; +use OCP\IUser; +use OCP\IGroup; +use OCP\ILogger; +use OCA\Search_Elastic\Connectors\ConnectorLegacy; +use OCA\Search_Elastic\Connectors\ElasticaFactory; +use Test\TestCase; + +class ConnectorLegacyTest extends TestCase { + /** @var Client */ + private $client; + /** @var ElasticaFactory */ + private $factory; + /** @var SearchElasticConfigService */ + private $esConfig; + /** @var IGroupManager */ + private $groupManager; + /** @var IUserManager */ + private $userManager; + /** @var ILogger */ + private $logger; + + /** @var ConnectorLegacy */ + private $connectorLegacy; + + protected function setUp(): void { + parent::setUp(); + + $this->client = $this->createMock(Client::class); + $this->factory = $this->createMock(ElasticaFactory::class); + $this->esConfig = $this->createMock(SearchElasticConfigService::class); + $this->groupManager = $this->createMock(IGroupManager::class); + $this->userManager = $this->createMock(IUserManager::class); + $this->logger = $this->createMock(ILogger::class); + + $this->connectorLegacy = new ConnectorLegacy( + $this->client, + $this->factory, + $this->esConfig, + $this->groupManager, + $this->userManager, + $this->logger + ); + } + + public function testGetConnectorName() { + $this->assertSame('Legacy', $this->connectorLegacy->getConnectorName()); + } + + public function testIsSetupMissingIndex() { + $indexMock = $this->createMock(Index::class); + $indexMock->expects($this->once()) + ->method('exists') + ->willReturn(false); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + // no request to check the ingest pipeline is needed + $this->client->expects($this->never()) + ->method('request'); + + $this->assertFalse($this->connectorLegacy->isSetup()); + } + + public function testIsSetupWrongPipeline() { + $this->esConfig->method('getRecommendedPrefixFor') + ->will($this->returnValueMap([ + ['index', 'oc-instanceid'], + ['processor', 'oc-processor-instanceid'], + ])); + + $indexMock = $this->createMock(Index::class); + $indexMock->expects($this->once()) + ->method('exists') + ->willReturn(true); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $response = $this->createMock(Response::class); + $response->method('getStatus')->willReturn(404); + + $this->client->expects($this->once()) + ->method('request') + ->with('_ingest/pipeline/oc-processor-instanceid', Request::GET) + ->willReturn($response); + + $this->assertFalse($this->connectorLegacy->isSetup()); + } + + public function testIsSetup() { + $this->esConfig->method('getRecommendedPrefixFor') + ->will($this->returnValueMap([ + ['index', 'oc-instanceid'], + ['processor', 'oc-processor-instanceid'], + ])); + + $indexMock = $this->createMock(Index::class); + $indexMock->expects($this->once()) + ->method('exists') + ->willReturn(true); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $response = $this->createMock(Response::class); + $response->method('getStatus')->willReturn(200); + + $this->client->expects($this->once()) + ->method('request') + ->with('_ingest/pipeline/oc-processor-instanceid', Request::GET) + ->willReturn($response); + + $this->assertTrue($this->connectorLegacy->isSetup()); + } + + public function testPrepareIndex() { + $this->esConfig->method('getRecommendedPrefixFor') + ->will($this->returnValueMap([ + ['index', 'oc-instanceid'], + ['processor', 'oc-processor-instanceid'], + ])); + + $expectedIndexConf = [ + 'number_of_shards' => 1, + 'number_of_replicas' => 0, + ]; + + $indexMock = $this->createMock(Index::class); + $indexMock->expects($this->once()) + ->method('create') + ->with(['settings' => $expectedIndexConf], true); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + // no specific mapping expected + $this->factory->expects($this->never()) + ->method('getNewMapping'); + + $expectedPayload = [ + 'description' => 'Pipeline to process entries for ownCloud search with connector Legacy', + 'processors' => [ + [ + 'attachment' => [ + 'field' => 'data', + 'target_field' => 'file', + 'indexed_chars' => '-1', + ] + ], + [ + 'remove' => [ + 'field' => 'data', + ] + ], + ], + ]; + + $this->client->expects($this->once()) + ->method('request') + ->with('_ingest/pipeline/oc-processor-instanceid', Request::PUT, $expectedPayload); + + $this->assertNull($this->connectorLegacy->prepareIndex()); + } + + public function testFetchResults() { + $this->esConfig->expects($this->once()) + ->method('getGroupNoContentArray') + ->willReturn([]); + $this->esConfig->expects($this->once()) + ->method('shouldContentBeIncluded') + ->willReturn(true); + + $userObj = $this->createMock(IUser::class); + $userObj->method('getUID')->willReturn('mockedUser'); + + $this->userManager->expects($this->once()) + ->method('get') + ->with('mockedUser', true) + ->willReturn($userObj); + + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID')->willReturn('G1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID')->willReturn('G2'); + $this->groupManager->expects($this->once()) + ->method('getUserGroups') + ->with($userObj) + ->willReturn([$group1, $group2]); + + $expectedQuery = [ + 'query' => [ + 'bool' => [ + 'filter' => [ + [ + 'bool' => [ + 'should' => [ + [ + 'match' => [ + 'users' => 'mockedUser', + ] + ], + [ + 'match' => [ + 'groups' => 'G1', + ], + ], + [ + 'match' => [ + 'groups' => 'G2', + ], + ], + ], + ], + ], + ], + 'should' => [ + [ + 'query_string' => [ + 'query' => 'test query*', + 'fields' => ['name'], + ], + ], + [ + 'query_string' => [ + 'query' => 'test* query*', + 'fields' => ['file.content'], + 'analyze_wildcard' => true, + ], + ], + ], + 'minimum_should_match' => 1, + ], + ], + 'highlight' => [ + 'fields' => ['file.content' => new \stdClass] + ], + '_source' => [ + 'includes' => ['mtime'] + ], + 'size' => 30, + 'from' => 0, + ]; + + $query = $this->createMock(Query::class); + $query->expects($this->once()) + ->method('setRawQuery') + ->with($expectedQuery); + + $this->factory->expects($this->once()) + ->method('getNewQuery') + ->willReturn($query); + + $indexMock = $this->createMock(Index::class); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $search = $this->createMock(Search::class); + $search->expects($this->once()) + ->method('addIndex') + ->with($indexMock); + + $this->factory->expects($this->once()) + ->method('getNewSearch') + ->with($this->client) + ->willReturn($search); + + // can't perform checks over the result set + $this->connectorLegacy->fetchResults('mockedUser', 'test query', 30, 0); + } + + public function testFetchResultsWithoutContent() { + $this->esConfig->expects($this->once()) + ->method('getGroupNoContentArray') + ->willReturn([]); + $this->esConfig->expects($this->once()) + ->method('shouldContentBeIncluded') + ->willReturn(false); + + $userObj = $this->createMock(IUser::class); + $userObj->method('getUID')->willReturn('mockedUser'); + + $this->userManager->expects($this->once()) + ->method('get') + ->with('mockedUser', true) + ->willReturn($userObj); + + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID')->willReturn('G1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID')->willReturn('G2'); + $this->groupManager->expects($this->once()) + ->method('getUserGroups') + ->with($userObj) + ->willReturn([$group1, $group2]); + + $expectedQuery = [ + 'query' => [ + 'bool' => [ + 'filter' => [ + [ + 'bool' => [ + 'should' => [ + [ + 'match' => [ + 'users' => 'mockedUser', + ] + ], + [ + 'match' => [ + 'groups' => 'G1', + ], + ], + [ + 'match' => [ + 'groups' => 'G2', + ], + ], + ], + ], + ], + ], + 'should' => [ + [ + 'query_string' => [ + 'query' => 'test query*', + 'fields' => ['name'], + ], + ], + ], + 'minimum_should_match' => 1, + ], + ], + 'highlight' => [ + 'fields' => ['file.content' => new \stdClass] + ], + '_source' => [ + 'includes' => ['mtime'] + ], + 'size' => 30, + 'from' => 0, + ]; + + $query = $this->createMock(Query::class); + $query->expects($this->once()) + ->method('setRawQuery') + ->with($expectedQuery); + + $this->factory->expects($this->once()) + ->method('getNewQuery') + ->willReturn($query); + + $indexMock = $this->createMock(Index::class); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $search = $this->createMock(Search::class); + $search->expects($this->once()) + ->method('addIndex') + ->with($indexMock); + + $this->factory->expects($this->once()) + ->method('getNewSearch') + ->with($this->client) + ->willReturn($search); + + // can't perform checks over the result set + $this->connectorLegacy->fetchResults('mockedUser', 'test query', 30, 0); + } + + public function testFetchResultsGroupNoContent() { + $this->esConfig->expects($this->once()) + ->method('getGroupNoContentArray') + ->willReturn(['G1']); + $this->esConfig->expects($this->once()) + ->method('shouldContentBeIncluded') + ->willReturn(true); + + $userObj = $this->createMock(IUser::class); + $userObj->method('getUID')->willReturn('mockedUser'); + + $this->userManager->expects($this->once()) + ->method('get') + ->with('mockedUser', true) + ->willReturn($userObj); + + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID')->willReturn('G1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID')->willReturn('G2'); + $this->groupManager->expects($this->once()) + ->method('getUserGroups') + ->with($userObj) + ->willReturn([$group1, $group2]); + + $expectedQuery = [ + 'query' => [ + 'bool' => [ + 'filter' => [ + [ + 'bool' => [ + 'should' => [ + [ + 'match' => [ + 'users' => 'mockedUser', + ] + ], + [ + 'match' => [ + 'groups' => 'G1', + ], + ], + [ + 'match' => [ + 'groups' => 'G2', + ], + ], + ], + ], + ], + ], + 'should' => [ + [ + 'query_string' => [ + 'query' => 'test query*', + 'fields' => ['name'], + ], + ], + ], + 'minimum_should_match' => 1, + ], + ], + 'highlight' => [ + 'fields' => ['file.content' => new \stdClass] + ], + '_source' => [ + 'includes' => ['mtime'] + ], + 'size' => 30, + 'from' => 0, + ]; + + $query = $this->createMock(Query::class); + $query->expects($this->once()) + ->method('setRawQuery') + ->with($expectedQuery); + + $this->factory->expects($this->once()) + ->method('getNewQuery') + ->willReturn($query); + + $indexMock = $this->createMock(Index::class); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $search = $this->createMock(Search::class); + $search->expects($this->once()) + ->method('addIndex') + ->with($indexMock); + + $this->factory->expects($this->once()) + ->method('getNewSearch') + ->with($this->client) + ->willReturn($search); + + // can't perform checks over the result set + $this->connectorLegacy->fetchResults('mockedUser', 'test query', 30, 0); + } + + public function testFindInResultId() { + $result = $this->createMock(Result::class); + $result->method('getId')->willReturn(987); + + $this->assertSame(987, $this->connectorLegacy->findInResult($result, 'id')); + } + + public function testFindInResultHighlight() { + $result = $this->createMock(Result::class); + $result->method('getHighlights')->willReturn([ + 'file.content' => ['high light number 1', 'another high'] + ]); + + $this->assertSame(['high light number 1', 'another high'], $this->connectorLegacy->findInResult($result, 'highlights')); + } + + public function testFindInResultMtime() { + $result = $this->createMock(Result::class); + $result->method('getData')->willReturn([ + 'mtime' => 123456, + 'size' => 9876, + 'name' => 'a random name', + ]); + + $this->assertSame(123456, $this->connectorLegacy->findInResult($result, 'mtime')); + } + + public function testDeleteByFileId() { + $response = $this->createMock(Response::class); + $response->method('isOk')->willReturn(true); + $response->method('getStatus')->willReturn(200); + + $indexMock = $this->createMock(Index::class); + $indexMock->expects($this->once()) + ->method('deleteById') + ->willReturn($response); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $this->assertTrue($this->connectorLegacy->deleteByFileId(50)); + } + + public function testDeleteByFileIdMissing() { + $response = $this->createMock(Response::class); + $response->method('isOk')->willReturn(false); + $response->method('getStatus')->willReturn(404); + + $indexMock = $this->createMock(Index::class); + $indexMock->expects($this->once()) + ->method('deleteById') + ->willReturn($response); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $this->assertTrue($this->connectorLegacy->deleteByFileId(50)); + } + + public function testDeleteByFileIdFailed() { + $response = $this->createMock(Response::class); + $response->method('isOk')->willReturn(false); + $response->method('getStatus')->willReturn(500); + + $indexMock = $this->createMock(Index::class); + $indexMock->expects($this->once()) + ->method('deleteById') + ->willReturn($response); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $this->assertFalse($this->connectorLegacy->deleteByFileId(50)); + } + + public function testGetStats() { + $stats = $this->createMock(Stats::class); + $stats->method('getData')->willReturn(['nodeCount' => 50]); + + $indexMock = $this->createMock(Index::class); + $indexMock->expects($this->once()) + ->method('getStats') + ->willReturn($stats); + + $this->factory->expects($this->once()) + ->method('getNewIndex') + ->willReturn($indexMock); + + $this->assertEquals(['nodeCount' => 50], $this->connectorLegacy->getStats()); + } +} diff --git a/tests/unit/lib/TestElasticSearchProvider.php b/tests/unit/lib/TestElasticSearchProvider.php deleted file mode 100644 index 28838ed6..00000000 --- a/tests/unit/lib/TestElasticSearchProvider.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * @copyright Copyright (c) 2021, ownCloud GmbH - * @license GPL-2.0 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -namespace OCA\Search_Elastic\Tests\Unit; - -use OCA\Search_Elastic\Search\ElasticSearchProvider; -use Test\TestCase; - -class TestElasticSearchProvider extends TestCase { - /** - * @var ElasticSearchProvider - */ - private $elasticSearchProvider; - - /** - * Set Up scenario - */ - public function setUp(): void { - $this->elasticSearchProvider = new ElasticSearchProvider([]); - } - - /** - * @return \string[][] - */ - public function provideQueries() { - return [ - ["test", "test*"], - ["*test", "*test"], - ["*test*", "*test*"], - ["this is a test", "this* is* a* test*"], - ["this is a +test", "this is a +test"], - ["this is a -test", "this is a -test"], - ["this is a-test", "this is a-test"], - ["\"this is a test\"", "\"this is a test\""], - ["this (is a test)", "this (is a test)"], - ["this is a testÑ", "this is a testÑ"], - ["this is a test?", "this is a test?"], - ["apple | red", "apple | red"], - ]; - } - - /** - * Test that the query format is working as expected - * - * @dataProvider provideQueries - * @param $query - * @param $result - */ - public function testFormatQuery($query, $result) { - self::assertEquals($result, $this->elasticSearchProvider->formatContentQuery($query)); - } -}