diff --git a/.travis.yml b/.travis.yml
index d95df8a0..d0b302e6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,15 +4,20 @@ php:
- 7.1
- 7.2
- 7.3
+ - 7.4
env:
global:
- - ES_VERSION=6.2.3 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
+ - ES_VERSION=7.5.2 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
matrix:
- - SYMFONY="~3.4"
- - SYMFONY="^4.1"
+ - SYMFONY="^4.4"
+ - SYMFONY="^5.0"
+jobs:
+ exclude:
+ - php: 7.1
+ env: SYMFONY="^5.0"
install:
- wget ${ES_DOWNLOAD_URL}
- - tar -xzf elasticsearch-${ES_VERSION}.tar.gz
+ - tar -xzf elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
before_script:
- composer require --no-update symfony/framework-bundle:${SYMFONY}
@@ -23,4 +28,4 @@ script:
- vendor/bin/phpunit --coverage-clover=coverage.clover
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,Tests/app/,var/cache ./
after_script:
- - travis_retry php vendor/bin/coveralls
+ - travis_retry bash <(curl -s https://codecov.io/bash)
diff --git a/Annotation/Index.php b/Annotation/Index.php
index d57db9e2..8cf3fadf 100644
--- a/Annotation/Index.php
+++ b/Annotation/Index.php
@@ -37,14 +37,6 @@ final class Index extends AbstractAnnotation
public $numberOfReplicas = 1;
- /**
- * We strongly recommend to not use this parameter in the index annotation. By default it will be set as `_doc`
- * type name. Eventually it will be removed.
- *
- * @deprecated will be removed in v7 since there will be no more types in the indexes.
- */
- public $typeName = '_doc';
-
/**
* You can select one of your indexes to be default. Useful for cli commands when you don't
* need to define an alias name. If default is not set the first index found will be set as default one.
diff --git a/Command/AbstractIndexServiceAwareCommand.php b/Command/AbstractIndexServiceAwareCommand.php
index eafa9fea..c9825dd4 100644
--- a/Command/AbstractIndexServiceAwareCommand.php
+++ b/Command/AbstractIndexServiceAwareCommand.php
@@ -14,12 +14,22 @@
use ONGR\ElasticsearchBundle\DependencyInjection\Configuration;
use ONGR\ElasticsearchBundle\Service\IndexService;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
+use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\DependencyInjection\Container;
-abstract class AbstractIndexServiceAwareCommand extends ContainerAwareCommand
+abstract class AbstractIndexServiceAwareCommand extends Command
{
+ private $container;
+
const INDEX_OPTION = 'index';
+ public function __construct(Container $container)
+ {
+ $this->container = $container;
+ parent::__construct();
+ }
+
protected function configure()
{
$this->addOption(
@@ -32,19 +42,24 @@ protected function configure()
protected function getIndex($name): IndexService
{
- $name = $name ?? $this->getContainer()->getParameter(Configuration::ONGR_DEFAULT_INDEX);
- $indexes = $this->getContainer()->getParameter(Configuration::ONGR_INDEXES);
+ $name = $name ?? $this->container->getParameter(Configuration::ONGR_DEFAULT_INDEX);
+ $indexes = $this->container->getParameter(Configuration::ONGR_INDEXES);
- if (isset($indexes[$name]) && $this->getContainer()->has($indexes[$name])) {
- return $this->getContainer()->get($indexes[$name]);
+ if (isset($indexes[$name]) && $this->container->has($indexes[$name])) {
+ return $this->container->get($indexes[$name]);
}
throw new \RuntimeException(
sprintf(
'There is no index under `%s` name found. Available options: `%s`.',
$name,
- implode('`, `', array_keys($this->getContainer()->getParameter(Configuration::ONGR_INDEXES)))
+ implode('`, `', array_keys($this->container->getParameter(Configuration::ONGR_INDEXES)))
)
);
}
+
+ public function getContainer(): Container
+ {
+ return $this->container;
+ }
}
diff --git a/Command/CacheClearCommand.php b/Command/CacheClearCommand.php
index 594e1e6c..956a572c 100644
--- a/Command/CacheClearCommand.php
+++ b/Command/CacheClearCommand.php
@@ -46,5 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$index->getIndexName()
)
);
+
+ return 0;
}
}
diff --git a/Command/DocumentGenerateCommand.php b/Command/DocumentGenerateCommand.php
deleted file mode 100644
index cf41f845..00000000
--- a/Command/DocumentGenerateCommand.php
+++ /dev/null
@@ -1,717 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace ONGR\ElasticsearchBundle\Command;
-
-use Symfony\Component\Console\Helper\FormatterHelper;
-use Symfony\Component\Console\Helper\QuestionHelper;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Question\ConfirmationQuestion;
-use Symfony\Component\Console\Question\Question;
-use Symfony\Component\HttpKernel\Kernel;
-
-class DocumentGenerateCommand extends AbstractIndexServiceAwareCommand
-{
- const NAME = 'ongr:es:document:generate';
-
- /**
- * @var QuestionHelper
- */
- private $questionHelper;
-
- /**
- * @var string[]
- */
- private $propertyAnnotations;
-
- /**
- * @var string[]
- */
- private $propertyVisibilities;
-
- /**
- * {@inheritdoc}
- */
- protected function configure()
- {
- parent::configure();
-
- $this
- ->setName(self::NAME)
- ->setDescription('Generates a new Elasticsearch document inside a bundle');
- }
-
- /**
- * {@inheritdoc}
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- if ($input->hasParameterOption(['--no-interaction', '-n'])) {
- throw $this->getException('No interaction mode is not allowed!');
- }
- }
-
- /**
- * {@inheritdoc}
- */
- protected function interact(InputInterface $input, OutputInterface $output)
- {
- /** @var FormatterHelper $formatter */
- $formatter = $this->getHelperSet()->get('formatter');
- $this->questionHelper = new QuestionHelper();
-
- $output->writeln(
- [
- '',
- $formatter->formatBlock('Welcome to the Elasticsearch Bundle document generator', 'bg=blue', true),
- '',
- 'This command helps you generate Elasticsearch documents.',
- '',
- 'First, you need to give the document class namespace you want to generate.',
- 'You must use the shortcut notation like
Enterprise E-commerce Accelerator.<\/p><\/div>","urls":[{"url":"home-page\/","key":""}]}} + {"_id":"15","_source":{"id":"15","title":"About","content":"Sample ONGR about page..","urls":[{"url":"about\/","key":""}]}}, + {"_id":"37","_source":{"id":"37","title":"Home Page","content":"
Enterprise E-commerce Accelerator.<\/p><\/div>","urls":[{"url":"home-page\/","key":""}]}} ] ``` @@ -62,7 +62,6 @@ So here's a simple example how the data looks like: Every line of file is `JSON` object. First line must specify `count`, how many lines are in the files except first and the file timestamp in `date`. There is one document per line. There could be different types defined in a single file, basically with a single file you can import the whole index. There are 3 required keys: -* `_type` which specifies elasticsearch type name (not an ElasticsearchBundle class document) * `_id` is optional, if not specified (provided `null`) elasticsearch will create a random id for that document. * `_source`: document array encoded to json object, where all fields are equal to the elasticsearch type field names. @@ -78,7 +77,6 @@ Exports data from Elasticsearch index in a json format. |:-----------:|:----------------------------:|:--------------------------------------------------------------------------------------:| | `--manager` | *Manager name. e.g.* `default` | Used to select manager to create index for. If not specified, default manager is used. | | `--chunk` | *Chunk size, default 500* | Specifies the size of each chunk to be received from Elasticsearch. This can be changed for performance reasons. -| `--types` | *Elasticsearch index type names* | Selected types to export, if no specified will export all index. | `--split` | *Lines number* | This option indicates how many lines can be in single exported file. > Index export generates the same `JSON` format as specified in the import chapter. diff --git a/Result/AbstractResultsIterator.php b/Result/AbstractResultsIterator.php index 39061833..f7a84520 100644 --- a/Result/AbstractResultsIterator.php +++ b/Result/AbstractResultsIterator.php @@ -52,8 +52,8 @@ public function __construct( if (isset($rawData['hits']['hits'])) { $this->documents = $rawData['hits']['hits']; } - if (isset($rawData['hits']['total'])) { - $this->count = $rawData['hits']['total']; + if (isset($rawData['hits']['total']['value'])) { + $this->count = $rawData['hits']['total']['value']; } } diff --git a/Service/ExportService.php b/Service/ExportService.php index 5b927549..6997a7e8 100644 --- a/Service/ExportService.php +++ b/Service/ExportService.php @@ -79,7 +79,7 @@ public function exportIndex( $counter = 0; } - $doc = array_intersect_key($data, array_flip(['_id', '_type', '_source'])); + $doc = array_intersect_key($data, array_flip(['_id', '_source'])); $writer->push($doc); $progress->advance(); $counter++; @@ -99,7 +99,7 @@ public function exportIndex( */ protected function getFilePath($filename): string { - if ($filename{0} == '/' || strstr($filename, ':') !== false) { + if ($filename[0] == '/' || strstr($filename, ':') !== false) { return $filename; } diff --git a/Service/ImportService.php b/Service/ImportService.php index 83cd73ba..3fa43572 100644 --- a/Service/ImportService.php +++ b/Service/ImportService.php @@ -65,7 +65,7 @@ public function importIndex( */ protected function getFilePath($filename) { - if ($filename{0} == '/' || strstr($filename, ':') !== false) { + if ($filename[0] == '/' || strstr($filename, ':') !== false) { return $filename; } diff --git a/Service/IndexService.php b/Service/IndexService.php index a9cc924f..51a8dd62 100644 --- a/Service/IndexService.php +++ b/Service/IndexService.php @@ -62,14 +62,6 @@ public function getNamespace(): string return $this->namespace; } - /** - * @deprecated will be removed in v7 since there will be no more types in the indexes. - */ - public function getTypeName(): string - { - return $this->indexSettings->getType(); - } - public function getIndexSettings() { return $this->indexSettings; @@ -90,8 +82,8 @@ public function getClient(): Client // $client->setLogger() $this->eventDispatcher->dispatch( - Events::POST_CLIENT_CREATE, - new PostCreateClientEvent($this->namespace, $client) + new PostCreateClientEvent($this->namespace, $client), + Events::POST_CLIENT_CREATE ); $this->client = $client->build(); } @@ -189,7 +181,6 @@ public function find($id, $params = []) { $requestParams = [ 'index' => $this->getIndexName(), - 'type' => $this->getTypeName(), 'id' => $id, ]; @@ -319,7 +310,6 @@ public function getIndexDocumentCount(): int { $body = [ 'index' => $this->getIndexName(), - 'type' => $this->getTypeName(), 'body' => [], ]; @@ -332,7 +322,6 @@ public function remove($id, $routing = null) { $params = [ 'index' => $this->getIndexName(), - 'type' => $this->getTypeName(), 'id' => $id, ]; @@ -358,7 +347,6 @@ public function update($id, array $fields = [], $script = null, array $params = [ 'id' => $id, 'index' => $this->getIndexName(), - 'type' => $this->getTypeName(), 'body' => $body, ], $params @@ -371,7 +359,6 @@ public function search(array $query, array $params = []): array { $requestParams = [ 'index' => $this->getIndexName(), - 'type' => $this->getTypeName(), 'body' => $query, ]; @@ -397,15 +384,14 @@ public function search(array $query, array $params = []): array public function bulk(string $operation, array $data = [], $autoCommit = true): array { $bulkParams = [ - '_type' => $this->getTypeName(), '_id' => $data['_id'] ?? null, ]; - unset($data['_index'], $data['_type'], $data['_id']); + unset($data['_index'], $data['_id']); $this->eventDispatcher->dispatch( - Events::BULK, - new BulkEvent($operation, $bulkParams, $data) + new BulkEvent($operation, $bulkParams, $data), + Events::BULK ); $this->bulkQueries[] = [ $operation => $bulkParams]; @@ -439,13 +425,13 @@ public function persist($document): void $this->bulk('index', $documentArray); } - public function commit($commitMode = 'flush', array $params = []): array + public function commit($commitMode = 'refresh', array $params = []): array { $bulkResponse = []; if (!empty($this->bulkQueries)) { $this->eventDispatcher->dispatch( - Events::PRE_COMMIT, - new CommitEvent($commitMode, $this->bulkQueries, []) + new CommitEvent($commitMode, $this->bulkQueries, []), + Events::PRE_COMMIT ); // $this->stopwatch('start', 'bulk'); @@ -483,8 +469,8 @@ public function commit($commitMode = 'flush', array $params = []): array } $this->eventDispatcher->dispatch( - Events::POST_COMMIT, - new CommitEvent($commitMode, $this->bulkQueries, $bulkResponse) + new CommitEvent($commitMode, $this->bulkQueries, $bulkResponse), + Events::POST_COMMIT ); $this->bulkQueries = []; diff --git a/Service/Json/JsonReader.php b/Service/Json/JsonReader.php index a31cee54..68deaef5 100644 --- a/Service/Json/JsonReader.php +++ b/Service/Json/JsonReader.php @@ -125,10 +125,9 @@ protected function readLine() protected function configureResolver(OptionsResolver $resolver) { $resolver - ->setRequired(['_id', '_type', '_source']) + ->setRequired(['_id', '_source']) ->setDefaults(['_score' => null, 'fields' => []]) ->addAllowedTypes('_id', ['integer', 'string']) - ->addAllowedTypes('_type', 'string') ->addAllowedTypes('_source', 'array') ->addAllowedTypes('fields', 'array'); } diff --git a/Test/AbstractElasticsearchTestCase.php b/Test/AbstractElasticsearchTestCase.php index e8f3f9e3..3c8bb523 100644 --- a/Test/AbstractElasticsearchTestCase.php +++ b/Test/AbstractElasticsearchTestCase.php @@ -53,7 +53,7 @@ protected function setUp() * * @return array */ - protected function getDataArray() + protected function getDataArray(): array { return []; } @@ -69,7 +69,7 @@ private function populateElastic(IndexService $indexService, array $documents = /** * {@inheritdoc} */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); @@ -85,7 +85,7 @@ protected function tearDown() protected function getContainer($reinitialize = false, $kernelOptions = []): ContainerInterface { if (!self::$cachedContainer && !$reinitialize) { - static::bootKernel($kernelOptions); +// static::bootKernel($kernelOptions); self::$cachedContainer = static::createClient(['environment' => 'test'])->getContainer(); } diff --git a/Tests/Functional/Annotation/DocumentTest.php b/Tests/Functional/Annotation/DocumentTest.php index 81ae51d8..78277058 100644 --- a/Tests/Functional/Annotation/DocumentTest.php +++ b/Tests/Functional/Annotation/DocumentTest.php @@ -17,12 +17,6 @@ class DocumentTest extends AbstractElasticsearchTestCase { - public function testDocumentTypeName() - { - $index = $this->getIndex(DummyDocumentInTheEntityDirectory::class, false); - $this->assertEquals('_doc', $index->getTypeName()); - } - public function testDocumentIndexName() { $index = $this->getIndex(DummyDocument::class, false); diff --git a/Tests/Functional/Annotation/PropertyTest.php b/Tests/Functional/Annotation/PropertyTest.php index d944a157..56cc8116 100644 --- a/Tests/Functional/Annotation/PropertyTest.php +++ b/Tests/Functional/Annotation/PropertyTest.php @@ -37,7 +37,7 @@ public function testPropertyTypeName() ], 'type' => 'text', ], - $meta['mappings']['_doc']['properties']['title'] + $meta['mappings']['properties']['title'] ); } } diff --git a/Tests/Functional/Command/CacheClearCommandTest.php b/Tests/Functional/Command/CacheClearCommandTest.php index 878dd536..9af0528b 100644 --- a/Tests/Functional/Command/CacheClearCommandTest.php +++ b/Tests/Functional/Command/CacheClearCommandTest.php @@ -70,8 +70,7 @@ public function testExecuteException() */ private function getCommand() { - $command = new CacheClearCommand(); - $command->setContainer($this->getContainer()); + $command = new CacheClearCommand($this->getContainer(true)); return $command; } diff --git a/Tests/Functional/Command/CreateIndexCommandTest.php b/Tests/Functional/Command/CreateIndexCommandTest.php index e185d24e..39de4c60 100644 --- a/Tests/Functional/Command/CreateIndexCommandTest.php +++ b/Tests/Functional/Command/CreateIndexCommandTest.php @@ -170,8 +170,7 @@ public function testIndexMappingDump() */ private function getCommandTester() { - $indexCreateCommand = new IndexCreateCommand(); - $indexCreateCommand->setContainer($this->getContainer()); + $indexCreateCommand = new IndexCreateCommand($this->getContainer()); $app = new Application(); $app->add($indexCreateCommand); diff --git a/Tests/Functional/Command/DropIndexCommandTest.php b/Tests/Functional/Command/DropIndexCommandTest.php index 2d040ec1..8c09859f 100644 --- a/Tests/Functional/Command/DropIndexCommandTest.php +++ b/Tests/Functional/Command/DropIndexCommandTest.php @@ -24,8 +24,7 @@ public function testExecute() $index = $this->getIndex(DummyDocument::class); $index->dropAndCreateIndex(); - $command = new IndexDropCommand(); - $command->setContainer($this->getContainer()); + $command = new IndexDropCommand($this->getContainer()); $app = new Application(); $app->add($command); diff --git a/Tests/Functional/Command/GenerateDocumentCommandTest.php b/Tests/Functional/Command/GenerateDocumentCommandTest.php deleted file mode 100644 index 48f163df..00000000 --- a/Tests/Functional/Command/GenerateDocumentCommandTest.php +++ /dev/null @@ -1,42 +0,0 @@ -markTestSkipped('Document generator will be implemented later.'); - -// $app = new Application(); -// $app->add($this->getCommand()); -// -// $command = $app->find('ongr:es:document:generate'); -// -// $tester = new CommandTester($command); -// $tester->execute(['command' => $command->getName()], ['interactive' => false]); -// $tester->execute( -// ['command' => $command->getName(), '--no-interaction' => true], -// ['interactive' => false] -// ); - } - - /** - * @return DocumentGenerateCommand - */ - private function getCommand() - { - $command = new DocumentGenerateCommand(); - $command->setContainer(self::createClient()->getContainer()); - - return $command; - } -} diff --git a/Tests/Functional/Command/IndexExportCommandTest.php b/Tests/Functional/Command/IndexExportCommandTest.php index 4eeb440f..2755ef87 100644 --- a/Tests/Functional/Command/IndexExportCommandTest.php +++ b/Tests/Functional/Command/IndexExportCommandTest.php @@ -20,22 +20,22 @@ class IndexExportCommandTest extends AbstractElasticsearchTestCase { - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ [ - '_id' => 'doc1', + '_id' => 1, 'title' => 'Foo Product', 'number' => 5.00, ], [ - '_id' => 'doc2', + '_id' => 2, 'title' => 'Bar Product', 'number' => 8.33, ], [ - '_id' => 'doc3', + '_id' => 3, 'title' => 'Lao Product', 'number' => 1.95, ], @@ -88,6 +88,9 @@ public function testIndexExport(array $options, array $expectedResults) ); $results = $this->parseResult(vfsStream::url('tmp/test.json'), count($expectedResults)); + usort($results, function ($a, $b) { + return (int)$a['_id'] <=> (int)$b['_id']; + }); $this->assertEquals($expectedResults, $results); } @@ -97,13 +100,11 @@ public function testIndexExport(array $options, array $expectedResults) private function transformDataToResult(string $class): array { $expectedResults = []; - $index = $this->getIndex($class); foreach ($this->getDataArray()[$class] as $document) { $id = $document['_id']; unset($document['_id']); $expectedResults[] = [ - '_type' => $index->getTypeName(), '_id' => $id, '_source' => $document, ]; @@ -119,8 +120,7 @@ private function transformDataToResult(string $class): array */ private function getCommandTester() { - $indexExportCommand = new IndexExportCommand(); - $indexExportCommand->setContainer($this->getContainer()); + $indexExportCommand = new IndexExportCommand($this->getContainer()); $app = new Application(); $app->add($indexExportCommand); @@ -148,21 +148,6 @@ private function parseResult($filePath, $expectedCount) $this->assertEquals($expectedCount, $metadata['count']); - usort( - $results, - function ($a, $b) { - if ($a['_type'] == $b['_type']) { - if ($a['_id'] == $b['_id']) { - return 0; - } - - return $a['_id'] < $b['_id'] ? -1 : 1; - } - - return $a['_type'] < $b['_type'] ? -1 : 1; - } - ); - return $results; } } diff --git a/Tests/Functional/Command/IndexImportCommandTest.php b/Tests/Functional/Command/IndexImportCommandTest.php index 31cd91e2..f63e6bd5 100644 --- a/Tests/Functional/Command/IndexImportCommandTest.php +++ b/Tests/Functional/Command/IndexImportCommandTest.php @@ -62,14 +62,14 @@ public function testIndexImport(int $bulkSize, int $realSize, string $filename) ] ); - +// $index->refresh(); $search = $index->createSearch()->addQuery(new MatchAllQuery())->setSize($realSize); $results = $index->findDocuments($search); $ids = []; /** @var DummyDocument $doc */ foreach ($results as $doc) { - $ids[] = substr($doc->id, 3); + $ids[] = (int)$doc->id; } sort($ids); $data = range(1, $realSize); @@ -110,7 +110,7 @@ public function testIndexImportWithGzipOption($bulkSize, $realSize, $filename) $ids = []; /** @var DummyDocument $doc */ foreach ($results as $doc) { - $ids[] = substr($doc->id, 3); + $ids[] = (int)$doc->id; } sort($ids); $data = range(1, $realSize); @@ -124,9 +124,6 @@ public function testIndexImportWithGzipOption($bulkSize, $realSize, $filename) */ private function getImportCommand() { - $command = new IndexImportCommand(); - $command->setContainer($this->getContainer()); - - return $command; + return new IndexImportCommand($this->getContainer()); } } diff --git a/Tests/Functional/Profiler/ElasticsearchProfilerTest.php b/Tests/Functional/Profiler/ElasticsearchProfilerTest.php index 646c6843..d670b6ee 100644 --- a/Tests/Functional/Profiler/ElasticsearchProfilerTest.php +++ b/Tests/Functional/Profiler/ElasticsearchProfilerTest.php @@ -24,7 +24,7 @@ class ElasticsearchProfilerTest extends AbstractElasticsearchTestCase /** * {@inheritdoc} */ - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ @@ -90,7 +90,6 @@ public function testGetQueries() 'method' => 'GET', 'httpParameters' => [], 'scheme' => 'http', - 'port' => 9200, ], $lastQuery, 'Logged data did not match expected data.' @@ -120,7 +119,6 @@ public function testGetTermQuery() 'method' => 'POST', 'httpParameters' => [], 'scheme' => 'http', - 'port' => 9200, ], $lastQuery, 'Logged data did not match expected data.' diff --git a/Tests/Functional/Result/AggregationIteratorFindTest.php b/Tests/Functional/Result/AggregationIteratorFindTest.php index fb471ed1..2b72f2fc 100644 --- a/Tests/Functional/Result/AggregationIteratorFindTest.php +++ b/Tests/Functional/Result/AggregationIteratorFindTest.php @@ -21,7 +21,7 @@ class AggregationIteratorFindTest extends AbstractElasticsearchTestCase /** * {@inheritdoc} */ - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ diff --git a/Tests/Functional/Result/ArrayIteratorTest.php b/Tests/Functional/Result/ArrayIteratorTest.php index 0eb275ff..a26930bf 100644 --- a/Tests/Functional/Result/ArrayIteratorTest.php +++ b/Tests/Functional/Result/ArrayIteratorTest.php @@ -21,7 +21,7 @@ class ArrayIteratorTest extends AbstractElasticsearchTestCase { - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ diff --git a/Tests/Functional/Result/DocumentIteratorTest.php b/Tests/Functional/Result/DocumentIteratorTest.php index 6be40c45..0fd97136 100644 --- a/Tests/Functional/Result/DocumentIteratorTest.php +++ b/Tests/Functional/Result/DocumentIteratorTest.php @@ -22,7 +22,7 @@ class DocumentIteratorTest extends AbstractElasticsearchTestCase { - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ diff --git a/Tests/Functional/Result/DocumentWithNullObjectFieldTest.php b/Tests/Functional/Result/DocumentWithNullObjectFieldTest.php index cee6ddb0..66643bbd 100644 --- a/Tests/Functional/Result/DocumentWithNullObjectFieldTest.php +++ b/Tests/Functional/Result/DocumentWithNullObjectFieldTest.php @@ -15,7 +15,7 @@ class DocumentNullObjectFieldTest extends AbstractElasticsearchTestCase { - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ diff --git a/Tests/Functional/Result/GetDocumentSortTest.php b/Tests/Functional/Result/GetDocumentSortTest.php index 3a938ff2..8805d9e3 100644 --- a/Tests/Functional/Result/GetDocumentSortTest.php +++ b/Tests/Functional/Result/GetDocumentSortTest.php @@ -18,7 +18,7 @@ class GetDocumentSortTest extends AbstractElasticsearchTestCase { - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ diff --git a/Tests/Functional/Result/ObjectIteratorTest.php b/Tests/Functional/Result/ObjectIteratorTest.php index 77117878..de30fb69 100644 --- a/Tests/Functional/Result/ObjectIteratorTest.php +++ b/Tests/Functional/Result/ObjectIteratorTest.php @@ -19,7 +19,7 @@ class ObjectIteratorTest extends AbstractElasticsearchTestCase { - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ diff --git a/Tests/Functional/Result/PersistObjectsTest.php b/Tests/Functional/Result/PersistObjectsTest.php index 2a4716cb..0ec90ba1 100644 --- a/Tests/Functional/Result/PersistObjectsTest.php +++ b/Tests/Functional/Result/PersistObjectsTest.php @@ -55,11 +55,13 @@ public function testAddingValuesToPrivateIdsWithoutSetters() $document = new IndexWithFieldsDataDocument(); $document->title = 'acme'; - $index->persist($document); $index->commit(); + $index->refresh(); + $document = $index->findOneBy(['private' => 'acme']); + $this->assertNotNull($document->getId()); } } diff --git a/Tests/Functional/Service/IndexServiceTest.php b/Tests/Functional/Service/IndexServiceTest.php index 6eb6dc00..5d277188 100644 --- a/Tests/Functional/Service/IndexServiceTest.php +++ b/Tests/Functional/Service/IndexServiceTest.php @@ -21,7 +21,7 @@ */ class ManagerTest extends AbstractElasticsearchTestCase { - protected function getDataArray() + protected function getDataArray(): array { return [ DummyDocument::class => [ diff --git a/Tests/Unit/Event/BulkEventTest.php b/Tests/Unit/Event/BulkEventTest.php index 7b91418a..20126b99 100644 --- a/Tests/Unit/Event/BulkEventTest.php +++ b/Tests/Unit/Event/BulkEventTest.php @@ -21,13 +21,11 @@ public function testGetters() $operation = 'create'; $header = [ '_index' => 'index', - '_type' => '_doc', '_id' => 15, ]; $expectedHeader = [ '_index' => 'index', - '_type' => '_doc', '_id' => 10, ]; diff --git a/Tests/Unit/Event/CommitEventTest.php b/Tests/Unit/Event/CommitEventTest.php index 4418bd54..d55e453b 100644 --- a/Tests/Unit/Event/CommitEventTest.php +++ b/Tests/Unit/Event/CommitEventTest.php @@ -21,7 +21,6 @@ public function testGetters() $query = [ [ '_index' => 'index', - '_type' => '_doc', '_id' => 10, ], [ diff --git a/Tests/Unit/Mapping/DocumentParserTest.php b/Tests/Unit/Mapping/DocumentParserTest.php index d6d6d501..c03767e1 100644 --- a/Tests/Unit/Mapping/DocumentParserTest.php +++ b/Tests/Unit/Mapping/DocumentParserTest.php @@ -31,11 +31,9 @@ public function testDocumentParsing() $expected = [ 'mappings' => [ - '_doc' => [ - 'properties' => [ - 'keyword_field' => [ - 'type' => 'keyword', - ] + 'properties' => [ + 'keyword_field' => [ + 'type' => 'keyword', ] ] ] @@ -51,8 +49,8 @@ public function testParsingWithMultiFieldsMapping() $indexMetadata = $parser->getIndexMetadata(new \ReflectionClass(TestDocument::class)); // Mapping definition for field "title" should be there - $this->assertNotEmpty($indexMetadata['mappings']['_doc']['properties']['title']); - $title_field_def = $indexMetadata['mappings']['_doc']['properties']['title']; + $this->assertNotEmpty($indexMetadata['mappings']['properties']['title']); + $title_field_def = $indexMetadata['mappings']['properties']['title']; // title should have `fields` sub-array $this->assertArrayHasKey('fields', $title_field_def); diff --git a/Tests/Unit/Result/AbstractResultsIteratorTest.php b/Tests/Unit/Result/AbstractResultsIteratorTest.php index 2fe363ff..7f8d7c85 100644 --- a/Tests/Unit/Result/AbstractResultsIteratorTest.php +++ b/Tests/Unit/Result/AbstractResultsIteratorTest.php @@ -47,11 +47,12 @@ public function testGetDocumentScore() { $rawData = [ 'hits' => [ - 'total' => 3, + 'total' => [ + 'value' => 3 + ], 'hits' => [ [ '_index' => 'test', - '_type' => '_doc', '_id' => 'foo', '_score' => 1, '_source' => [ @@ -60,7 +61,6 @@ public function testGetDocumentScore() ], [ '_index' => 'test', - '_type' => 'product', '_id' => 'bar', '_score' => 2, '_source' => [ @@ -69,7 +69,6 @@ public function testGetDocumentScore() ], [ '_index' => 'test', - '_type' => 'product', '_id' => 'baz', '_score' => null, '_source' => [ @@ -89,7 +88,7 @@ public function testGetDocumentScore() $expectedScores = [1, 2, null]; $actualScores = []; - $this->assertEquals($rawData['hits']['total'], $results->count()); + $this->assertEquals($rawData['hits']['total']['value'], $results->count()); $this->assertEquals($rawData, $results->getRaw()); foreach ($results as $item) { diff --git a/Tests/Unit/Result/DocumentIteratorTest.php b/Tests/Unit/Result/DocumentIteratorTest.php index f19fde65..4ccfb975 100644 --- a/Tests/Unit/Result/DocumentIteratorTest.php +++ b/Tests/Unit/Result/DocumentIteratorTest.php @@ -42,7 +42,6 @@ public function testResultConvert() 'hits' => [ [ '_index' => 'test', - '_type' => '_doc', '_id' => 'foo', '_score' => 1, '_source' => [ diff --git a/Tests/Unit/Result/RawIteratorTest.php b/Tests/Unit/Result/RawIteratorTest.php index 4017b108..99930705 100644 --- a/Tests/Unit/Result/RawIteratorTest.php +++ b/Tests/Unit/Result/RawIteratorTest.php @@ -50,7 +50,6 @@ public function testIterator() 'hits' => [ [ '_index' => 'test', - '_type' => '_doc', '_id' => 'foo', '_score' => 1, '_source' => [ diff --git a/Tests/app/data_seed/command_import_10.json b/Tests/app/data_seed/command_import_10.json index c7025d41..9ad254fc 100644 --- a/Tests/app/data_seed/command_import_10.json +++ b/Tests/app/data_seed/command_import_10.json @@ -1,13 +1,13 @@ [ {"count":10}, - {"_type":"product","_id":"doc1","_source":{"title":"Document 1"}}, - {"_type":"product","_id":"doc2","_source":{"title":"Document 2"}}, - {"_type":"product","_id":"doc3","_source":{"title":"Document 3"}}, - {"_type":"product","_id":"doc4","_source":{"title":"Document 4"}}, - {"_type":"product","_id":"doc5","_source":{"title":"Document 5"}}, - {"_type":"product","_id":"doc6","_source":{"title":"Document 6"}}, - {"_type":"product","_id":"doc7","_source":{"title":"Document 7"}}, - {"_type":"product","_id":"doc8","_source":{"title":"Document 8"}}, - {"_type":"product","_id":"doc9","_source":{"title":"Document 9"}}, - {"_type":"product","_id":"doc10","_source":{"title":"Document 10"}} + {"_id":"1","_source":{"title":"Document 1"}}, + {"_id":"2","_source":{"title":"Document 2"}}, + {"_id":"3","_source":{"title":"Document 3"}}, + {"_id":"4","_source":{"title":"Document 4"}}, + {"_id":"5","_source":{"title":"Document 5"}}, + {"_id":"6","_source":{"title":"Document 6"}}, + {"_id":"7","_source":{"title":"Document 7"}}, + {"_id":"8","_source":{"title":"Document 8"}}, + {"_id":"9","_source":{"title":"Document 9"}}, + {"_id":"10","_source":{"title":"Document 10"}} ] diff --git a/Tests/app/data_seed/command_import_10.json.gz b/Tests/app/data_seed/command_import_10.json.gz index afd98cb4..ab344b14 100644 Binary files a/Tests/app/data_seed/command_import_10.json.gz and b/Tests/app/data_seed/command_import_10.json.gz differ diff --git a/Tests/app/data_seed/command_import_11.json b/Tests/app/data_seed/command_import_11.json index 65ecfffc..8d82e901 100644 --- a/Tests/app/data_seed/command_import_11.json +++ b/Tests/app/data_seed/command_import_11.json @@ -1,14 +1,14 @@ [ {"count":11}, - {"_type":"product","_id":"doc1","_source":{"title":"Document 1"}}, - {"_type":"product","_id":"doc2","_source":{"title":"Document 2"}}, - {"_type":"product","_id":"doc3","_source":{"title":"Document 3"}}, - {"_type":"product","_id":"doc4","_source":{"title":"Document 4"}}, - {"_type":"product","_id":"doc5","_source":{"title":"Document 5"}}, - {"_type":"product","_id":"doc6","_source":{"title":"Document 6"}}, - {"_type":"product","_id":"doc7","_source":{"title":"Document 7"}}, - {"_type":"product","_id":"doc8","_source":{"title":"Document 8"}}, - {"_type":"product","_id":"doc9","_source":{"title":"Document 9"}}, - {"_type":"product","_id":"doc10","_source":{"title":"Document 10"}}, - {"_type":"product","_id":"doc11","_source":{"title":"Document 11"}} + {"_id":"1","_source":{"title":"Document 1"}}, + {"_id":"2","_source":{"title":"Document 2"}}, + {"_id":"3","_source":{"title":"Document 3"}}, + {"_id":"4","_source":{"title":"Document 4"}}, + {"_id":"5","_source":{"title":"Document 5"}}, + {"_id":"6","_source":{"title":"Document 6"}}, + {"_id":"7","_source":{"title":"Document 7"}}, + {"_id":"8","_source":{"title":"Document 8"}}, + {"_id":"9","_source":{"title":"Document 9"}}, + {"_id":"10","_source":{"title":"Document 10"}}, + {"_id":"11","_source":{"title":"Document 11"}} ] \ No newline at end of file diff --git a/Tests/app/data_seed/command_import_11.json.gz b/Tests/app/data_seed/command_import_11.json.gz index 27864e70..2d2e5265 100644 Binary files a/Tests/app/data_seed/command_import_11.json.gz and b/Tests/app/data_seed/command_import_11.json.gz differ diff --git a/Tests/app/data_seed/command_import_20.json b/Tests/app/data_seed/command_import_20.json index b6e7e639..2b6441d3 100644 --- a/Tests/app/data_seed/command_import_20.json +++ b/Tests/app/data_seed/command_import_20.json @@ -1,23 +1,23 @@ [ {"count":20}, - {"_type":"product","_id":"doc1","_source":{"title":"Document 1"}}, - {"_type":"product","_id":"doc2","_source":{"title":"Document 2"}}, - {"_type":"product","_id":"doc3","_source":{"title":"Document 3"}}, - {"_type":"product","_id":"doc4","_source":{"title":"Document 4"}}, - {"_type":"product","_id":"doc5","_source":{"title":"Document 5"}}, - {"_type":"product","_id":"doc6","_source":{"title":"Document 6"}}, - {"_type":"product","_id":"doc7","_source":{"title":"Document 7"}}, - {"_type":"product","_id":"doc8","_source":{"title":"Document 8"}}, - {"_type":"product","_id":"doc9","_source":{"title":"Document 9"}}, - {"_type":"product","_id":"doc10","_source":{"title":"Document 10"}}, - {"_type":"product","_id":"doc11","_source":{"title":"Document 11"}}, - {"_type":"product","_id":"doc12","_source":{"title":"Document 12"}}, - {"_type":"product","_id":"doc13","_source":{"title":"Document 13"}}, - {"_type":"product","_id":"doc14","_source":{"title":"Document 14"}}, - {"_type":"product","_id":"doc15","_source":{"title":"Document 15"}}, - {"_type":"product","_id":"doc16","_source":{"title":"Document 16"}}, - {"_type":"product","_id":"doc17","_source":{"title":"Document 17"}}, - {"_type":"product","_id":"doc18","_source":{"title":"Document 18"}}, - {"_type":"product","_id":"doc19","_source":{"title":"Document 19"}}, - {"_type":"product","_id":"doc20","_source":{"title":"Document 20"}} + {"_id":"1","_source":{"title":"Document 1"}}, + {"_id":"2","_source":{"title":"Document 2"}}, + {"_id":"3","_source":{"title":"Document 3"}}, + {"_id":"4","_source":{"title":"Document 4"}}, + {"_id":"5","_source":{"title":"Document 5"}}, + {"_id":"6","_source":{"title":"Document 6"}}, + {"_id":"7","_source":{"title":"Document 7"}}, + {"_id":"8","_source":{"title":"Document 8"}}, + {"_id":"9","_source":{"title":"Document 9"}}, + {"_id":"10","_source":{"title":"Document 10"}}, + {"_id":"11","_source":{"title":"Document 11"}}, + {"_id":"12","_source":{"title":"Document 12"}}, + {"_id":"13","_source":{"title":"Document 13"}}, + {"_id":"14","_source":{"title":"Document 14"}}, + {"_id":"15","_source":{"title":"Document 15"}}, + {"_id":"16","_source":{"title":"Document 16"}}, + {"_id":"17","_source":{"title":"Document 17"}}, + {"_id":"18","_source":{"title":"Document 18"}}, + {"_id":"19","_source":{"title":"Document 19"}}, + {"_id":"20","_source":{"title":"Document 20"}} ] \ No newline at end of file diff --git a/Tests/app/data_seed/command_import_9.json b/Tests/app/data_seed/command_import_9.json index 1298abaa..b0f5d5cd 100644 --- a/Tests/app/data_seed/command_import_9.json +++ b/Tests/app/data_seed/command_import_9.json @@ -1,12 +1,12 @@ [ {"count":9}, - {"_type":"product","_id":"doc1","_source":{"title":"Document 1"}}, - {"_type":"product","_id":"doc2","_source":{"title":"Document 2"}}, - {"_type":"product","_id":"doc3","_source":{"title":"Document 3"}}, - {"_type":"product","_id":"doc4","_source":{"title":"Document 4"}}, - {"_type":"product","_id":"doc5","_source":{"title":"Document 5"}}, - {"_type":"product","_id":"doc6","_source":{"title":"Document 6"}}, - {"_type":"product","_id":"doc7","_source":{"title":"Document 7"}}, - {"_type":"product","_id":"doc8","_source":{"title":"Document 8"}}, - {"_type":"product","_id":"doc9","_source":{"title":"Document 9"}} + {"_id":"1","_source":{"title":"Document 1"}}, + {"_id":"2","_source":{"title":"Document 2"}}, + {"_id":"3","_source":{"title":"Document 3"}}, + {"_id":"4","_source":{"title":"Document 4"}}, + {"_id":"5","_source":{"title":"Document 5"}}, + {"_id":"6","_source":{"title":"Document 6"}}, + {"_id":"7","_source":{"title":"Document 7"}}, + {"_id":"8","_source":{"title":"Document 8"}}, + {"_id":"9","_source":{"title":"Document 9"}} ] diff --git a/Tests/app/data_seed/command_import_9.json.gz b/Tests/app/data_seed/command_import_9.json.gz index a0404a05..b6434b03 100644 Binary files a/Tests/app/data_seed/command_import_9.json.gz and b/Tests/app/data_seed/command_import_9.json.gz differ diff --git a/composer.json b/composer.json index 5a798852..12c90413 100644 --- a/composer.json +++ b/composer.json @@ -12,33 +12,32 @@ ], "require": { "php": "^7.1", - "symfony/framework-bundle": "^3.4|^4.1", - "symfony/dependency-injection": "^3.4|^4.1", - "symfony/console": "^3.4|^4.1", - "symfony/stopwatch": "^3.4|^4.1", - "symfony/finder": "^3.4|^4.1", - "symfony/serializer": "^3.4|^4.1", - "symfony/cache": "^3.4|^4.1", - "symfony/property-access": "^3.4|^4.1", + "symfony/framework-bundle": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/stopwatch": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/serializer": "^4.4|^5.0", + "symfony/cache": "^4.4|^5.0", + "symfony/property-access": "^4.4|^5.0", "doctrine/annotations": "^1.6", "doctrine/cache": "^1.7", "doctrine/inflector": "^1.3", "doctrine/collections": "^1.5", "monolog/monolog": "^1.24", - "elasticsearch/elasticsearch": "^6.0", - "ongr/elasticsearch-dsl": "^6.0" + "elasticsearch/elasticsearch": "^7.0", + "ongr/elasticsearch-dsl": "^7.0" }, "require-dev": { "mikey179/vfsstream": "~1.6", "phpunit/phpunit": "^7.0", "squizlabs/php_codesniffer": "^3.0", - "php-coveralls/php-coveralls": "^2.1", - "symfony/browser-kit" : "^3.4|^4.1", - "symfony/expression-language" : "^3.4|^4.1", - "symfony/twig-bundle": "^3.4|^4.1", - "symfony/yaml": "^3.4|^4.1", - "symfony/validator": "^3.4|^4.1", - "symfony/options-resolver": "^3.4|^4.1" + "symfony/browser-kit" : "^4.4|^5.0", + "symfony/expression-language" : "^4.4|^5.0", + "symfony/twig-bundle": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", + "symfony/options-resolver": "^4.4|^5.0" }, "autoload": { "psr-4": { "ONGR\\ElasticsearchBundle\\": "" }, @@ -55,7 +54,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "6.2-dev" + "dev-master": "7.0-dev" } } }