From a27a4d95eead0fd08b4d813f753cfc12a51c7648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Mon, 30 Dec 2019 11:13:14 +0200 Subject: [PATCH 01/11] update dev version for the branch --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 988b1e0a..5a798852 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "6.1-dev" + "dev-master": "6.2-dev" } } } From 0a0d317dafdb900cda1836ae21a6b3008f2a356c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Tue, 4 Feb 2020 18:45:32 +0200 Subject: [PATCH 02/11] add es7 support --- .travis.yml | 4 +- Annotation/Index.php | 8 --- DependencyInjection/Compiler/MappingPass.php | 1 - Mapping/DocumentParser.php | 36 +--------- Mapping/IndexSettings.php | 22 +----- Resources/doc/commands.md | 6 +- Result/AbstractResultsIterator.php | 4 +- Service/ExportService.php | 2 +- Service/IndexService.php | 16 +---- Service/Json/JsonReader.php | 3 +- Tests/Functional/Annotation/DocumentTest.php | 6 -- Tests/Functional/Annotation/PropertyTest.php | 2 +- .../Command/IndexExportCommandTest.php | 16 ----- .../Command/IndexImportCommandTest.php | 65 +++++++++--------- .../Profiler/ElasticsearchProfilerTest.php | 2 - Tests/Unit/Event/BulkEventTest.php | 2 - Tests/Unit/Event/CommitEventTest.php | 1 - Tests/Unit/Mapping/DocumentParserTest.php | 12 ++-- .../Result/AbstractResultsIteratorTest.php | 3 - Tests/Unit/Result/DocumentIteratorTest.php | 1 - Tests/Unit/Result/RawIteratorTest.php | 1 - Tests/app/data_seed/command_import_10.json | 20 +++--- Tests/app/data_seed/command_import_10.json.gz | Bin 177 -> 0 bytes Tests/app/data_seed/command_import_11.json | 22 +++--- Tests/app/data_seed/command_import_11.json.gz | Bin 180 -> 0 bytes Tests/app/data_seed/command_import_20.json | 40 +++++------ Tests/app/data_seed/command_import_9.json | 18 ++--- Tests/app/data_seed/command_import_9.json.gz | Bin 167 -> 0 bytes composer.json | 6 +- 29 files changed, 102 insertions(+), 217 deletions(-) delete mode 100644 Tests/app/data_seed/command_import_10.json.gz delete mode 100644 Tests/app/data_seed/command_import_11.json.gz delete mode 100644 Tests/app/data_seed/command_import_9.json.gz diff --git a/.travis.yml b/.travis.yml index d95df8a0..55865b55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,10 @@ php: - 7.3 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}.tar.gz matrix: - SYMFONY="~3.4" - - SYMFONY="^4.1" + - SYMFONY="^4.4" install: - wget ${ES_DOWNLOAD_URL} - tar -xzf elasticsearch-${ES_VERSION}.tar.gz 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/DependencyInjection/Compiler/MappingPass.php b/DependencyInjection/Compiler/MappingPass.php index dc739659..e0b8ee0f 100644 --- a/DependencyInjection/Compiler/MappingPass.php +++ b/DependencyInjection/Compiler/MappingPass.php @@ -93,7 +93,6 @@ private function handleDirectoryMapping(ContainerBuilder $container, string $dir $indexMetadata, $indexesOverride[$namespace]['hosts'] ?? $document->hosts, $indexesOverride[$namespace]['default'] ?? $document->default, - $indexesOverride[$namespace]['type'] ?? $document->typeName ] ); diff --git a/Mapping/DocumentParser.php b/Mapping/DocumentParser.php index b929bce2..fa1c2d88 100644 --- a/Mapping/DocumentParser.php +++ b/Mapping/DocumentParser.php @@ -72,17 +72,6 @@ public function getIndexAnnotation(\ReflectionClass $class) return $document; } - /** - * @deprecated will be deleted in v7. Types are deleted from elasticsearch. - */ - public function getTypeName(\ReflectionClass $class): string - { - /** @var Index $document */ - $document = $this->reader->getClassAnnotation($class, Index::class); - - return $document->typeName ?? '_doc'; - } - public function getIndexMetadata(\ReflectionClass $class): array { if ($class->isTrait()) { @@ -102,34 +91,11 @@ public function getIndexMetadata(\ReflectionClass $class): array return array_filter(array_map('array_filter', [ 'settings' => $settings, 'mappings' => [ - $this->getTypeName($class) => [ - 'properties' => array_filter($this->getClassMetadata($class)) - ] + 'properties' => array_filter($this->getClassMetadata($class)) ] ])); } - public function getDocumentNamespace(string $indexAlias): ?string - { - if ($this->cache->contains(Configuration::ONGR_INDEXES)) { - $indexes = $this->cache->fetch(Configuration::ONGR_INDEXES); - - if (isset($indexes[$indexAlias])) { - return $indexes[$indexAlias]; - } - } - - return null; - } - - public function getParsedDocument(\ReflectionClass $class): Index - { - /** @var Index $document */ - $document = $this->reader->getClassAnnotation($class, Index::class); - - return $document; - } - private function getClassMetadata(\ReflectionClass $class): array { $mapping = []; diff --git a/Mapping/IndexSettings.php b/Mapping/IndexSettings.php index 96af7549..81296fc9 100644 --- a/Mapping/IndexSettings.php +++ b/Mapping/IndexSettings.php @@ -19,21 +19,13 @@ class IndexSettings private $hosts; private $defaultIndex = false; - - - /** - * @deprecated will be removed in the v7 - */ - private $type; - public function __construct( string $namespace, string $indexName, string $alias, array $indexMetadata = [], array $hosts = [], - bool $defaultIndex = false, - $type = null + bool $defaultIndex = false ) { $this->namespace = $namespace; $this->indexName = $indexName; @@ -41,7 +33,6 @@ public function __construct( $this->indexMetadata = $indexMetadata; $this->hosts = $hosts; $this->defaultIndex = $defaultIndex; - $this->type = $type; } public function getNamespace() @@ -109,15 +100,4 @@ public function setDefaultIndex(bool $defaultIndex): self $this->defaultIndex = $defaultIndex; return $this; } - - public function getType() - { - return $this->type; - } - - public function setType($type): self - { - $this->type = $type; - return $this; - } } diff --git a/Resources/doc/commands.md b/Resources/doc/commands.md index 3b5b5efb..68afa492 100644 --- a/Resources/doc/commands.md +++ b/Resources/doc/commands.md @@ -53,8 +53,8 @@ So here's a simple example how the data looks like: [ {"count":2,"date":"2015-10-25T14:46:21+0200"}, - {"_type":"content","_id":"15","_source":{"id":"15","title":"About","content":"Sample ONGR about page..","urls":[{"url":"about\/","key":""}]}}, - {"_type":"content","_id":"37","_source":{"id":"37","title":"Home Page","content":"
\r\n

Welcome to ONGR demo site!<\/h1>\r\n

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":"

\r\n

Welcome to ONGR demo site!<\/h1>\r\n

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..fba2949f 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++; diff --git a/Service/IndexService.php b/Service/IndexService.php index a9cc924f..83aaf6da 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; @@ -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,11 +384,10 @@ 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, 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/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/IndexExportCommandTest.php b/Tests/Functional/Command/IndexExportCommandTest.php index 4eeb440f..c49cce28 100644 --- a/Tests/Functional/Command/IndexExportCommandTest.php +++ b/Tests/Functional/Command/IndexExportCommandTest.php @@ -103,7 +103,6 @@ private function transformDataToResult(string $class): array $id = $document['_id']; unset($document['_id']); $expectedResults[] = [ - '_type' => $index->getTypeName(), '_id' => $id, '_source' => $document, ]; @@ -148,21 +147,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..15c9f1ed 100644 --- a/Tests/Functional/Command/IndexImportCommandTest.php +++ b/Tests/Functional/Command/IndexImportCommandTest.php @@ -62,14 +62,13 @@ public function testIndexImport(int $bulkSize, int $realSize, string $filename) ] ); - $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); @@ -85,37 +84,37 @@ public function testIndexImport(int $bulkSize, int $realSize, string $filename) * * @dataProvider compressedDataProvider */ - public function testIndexImportWithGzipOption($bulkSize, $realSize, $filename) - { - $index = $this->getIndex(DummyDocument::class); - - $app = new Application(); - $app->add($this->getImportCommand()); - - $command = $app->find('ongr:es:index:import'); - $commandTester = new CommandTester($command); - $commandTester->execute( - [ - 'command' => $command->getName(), - 'filename' => __DIR__ . '/../../app/data_seed/' . $filename, - '--bulk-size' => $bulkSize, - '--gzip' => null, - ] - ); - - - $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); - } - sort($ids); - $data = range(1, $realSize); - $this->assertEquals($data, $ids); - } +// public function testIndexImportWithGzipOption($bulkSize, $realSize, $filename) +// { +// $index = $this->getIndex(DummyDocument::class); +// +// $app = new Application(); +// $app->add($this->getImportCommand()); +// +// $command = $app->find('ongr:es:index:import'); +// $commandTester = new CommandTester($command); +// $commandTester->execute( +// [ +// 'command' => $command->getName(), +// 'filename' => __DIR__ . '/../../app/data_seed/' . $filename, +// '--bulk-size' => $bulkSize, +// '--gzip' => null, +// ] +// ); +// +// +// $search = $index->createSearch()->addQuery(new MatchAllQuery())->setSize($realSize); +// $results = $index->findDocuments($search); +// +// $ids = []; +// /** @var DummyDocument $doc */ +// foreach ($results as $doc) { +// $ids[] = (int)$doc->id; +// } +// sort($ids); +// $data = range(1, $realSize); +// $this->assertEquals($data, $ids); +// } /** * Returns import index command with assigned container. diff --git a/Tests/Functional/Profiler/ElasticsearchProfilerTest.php b/Tests/Functional/Profiler/ElasticsearchProfilerTest.php index 646c6843..32cd27a7 100644 --- a/Tests/Functional/Profiler/ElasticsearchProfilerTest.php +++ b/Tests/Functional/Profiler/ElasticsearchProfilerTest.php @@ -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/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..591de697 100644 --- a/Tests/Unit/Result/AbstractResultsIteratorTest.php +++ b/Tests/Unit/Result/AbstractResultsIteratorTest.php @@ -51,7 +51,6 @@ public function testGetDocumentScore() 'hits' => [ [ '_index' => 'test', - '_type' => '_doc', '_id' => 'foo', '_score' => 1, '_source' => [ @@ -60,7 +59,6 @@ public function testGetDocumentScore() ], [ '_index' => 'test', - '_type' => 'product', '_id' => 'bar', '_score' => 2, '_source' => [ @@ -69,7 +67,6 @@ public function testGetDocumentScore() ], [ '_index' => 'test', - '_type' => 'product', '_id' => 'baz', '_score' => null, '_source' => [ 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 deleted file mode 100644 index afd98cb4663f4234bf1027c9fd44c2e9fbeae4db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 177 zcmV;i08alOiwFp=E{|3K17mM(ZDDR?UukV{Z*p{BF)%J_b8l_{jnX>~gD?<;;ohgP zwx+OoL!Dbh5yhGUDZz-W3xv3POfE26{?h2H=4q@wiDO!YM(?iT-;*5MOe1Z342gvb znwF3|MD}-lW7;_nPLf65_wo@redblHrwbz`KuQf#0i@C(H9%?&(g38Os=K#{vKVGNeqj 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 deleted file mode 100644 index 27864e70ec10068d296463de4e8c2e6ef42ed0a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 180 zcmV;l089TLiwFq3E{|3K17mM(ZDDR?UukV{Z*p{BF)=P`b8l_{jnX>~gFp;~;hs~h zTvK4)Q0Ep=M6pYOlwd@>1w!0CY%VY^e`)kp^URz($xB?7M&>L3_oT-*(@5JcA$p~p zrX}1R#B++T#NFS6lXTH{T0X?b&%CN*x-e1#q_iLvKq?DT1EjVf4L}+T(gLKlARRzD i3(^Cmw;%&R1`EOkdRt*);Azuqv)2!M__&1)0{{T}KTK`_ 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 deleted file mode 100644 index a0404a0503e4e440cb5d5e53f989beb94fe4bd8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 167 zcmV;Y09gMYiwFpq*o{^I17mM(ZDDR?UukV{Z*p{BIWB5*Z*BmM%sUQ)Fc3x2-m9>t zrs0pNvx_LA7*il63?kzKA@&}V4ZJC@bakH2`;%DGsx*eH_~)d@Hq%JkE-|rELDLd* zN8$30ucV#xaFQ Date: Tue, 4 Feb 2020 18:49:30 +0200 Subject: [PATCH 03/11] update elasticsearch download url --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 55865b55..9667ac48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ php: - 7.3 env: global: - - ES_VERSION=7.5.2 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz + - ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.2-linux-x86_64.tar.gz matrix: - SYMFONY="~3.4" - SYMFONY="^4.4" From 1fc96bf2c7154eca806b28e9dbb7dbbe86e08d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Tue, 4 Feb 2020 18:51:51 +0200 Subject: [PATCH 04/11] fix that travis could extract elastic --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9667ac48..fd8b67b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,13 @@ php: - 7.3 env: global: - - ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.2-linux-x86_64.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.4" 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} From c49241c0643886f4d110c56b29f357b8c19b7e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Tue, 4 Feb 2020 20:58:45 +0200 Subject: [PATCH 05/11] fix incompatibilities --- Service/IndexService.php | 2 +- Tests/Functional/Command/IndexExportCommandTest.php | 10 ++++++---- Tests/Functional/Command/IndexImportCommandTest.php | 1 + Tests/Functional/Result/PersistObjectsTest.php | 4 +++- Tests/Unit/Result/AbstractResultsIteratorTest.php | 6 ++++-- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Service/IndexService.php b/Service/IndexService.php index 83aaf6da..4688d6b6 100644 --- a/Service/IndexService.php +++ b/Service/IndexService.php @@ -425,7 +425,7 @@ 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)) { diff --git a/Tests/Functional/Command/IndexExportCommandTest.php b/Tests/Functional/Command/IndexExportCommandTest.php index c49cce28..8788e13a 100644 --- a/Tests/Functional/Command/IndexExportCommandTest.php +++ b/Tests/Functional/Command/IndexExportCommandTest.php @@ -25,17 +25,17 @@ protected function getDataArray() 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,7 +100,6 @@ 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']; diff --git a/Tests/Functional/Command/IndexImportCommandTest.php b/Tests/Functional/Command/IndexImportCommandTest.php index 15c9f1ed..cd824d22 100644 --- a/Tests/Functional/Command/IndexImportCommandTest.php +++ b/Tests/Functional/Command/IndexImportCommandTest.php @@ -62,6 +62,7 @@ public function testIndexImport(int $bulkSize, int $realSize, string $filename) ] ); +// $index->refresh(); $search = $index->createSearch()->addQuery(new MatchAllQuery())->setSize($realSize); $results = $index->findDocuments($search); 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/Unit/Result/AbstractResultsIteratorTest.php b/Tests/Unit/Result/AbstractResultsIteratorTest.php index 591de697..7f8d7c85 100644 --- a/Tests/Unit/Result/AbstractResultsIteratorTest.php +++ b/Tests/Unit/Result/AbstractResultsIteratorTest.php @@ -47,7 +47,9 @@ public function testGetDocumentScore() { $rawData = [ 'hits' => [ - 'total' => 3, + 'total' => [ + 'value' => 3 + ], 'hits' => [ [ '_index' => 'test', @@ -86,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) { From b4f30fa1c8ebbf2d94adc24e5759be164fbd8fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Wed, 5 Feb 2020 08:35:25 +0200 Subject: [PATCH 06/11] adjust the import test when gzip is used gzip --- .../Command/IndexImportCommandTest.php | 62 +++++++++--------- Tests/app/data_seed/command_import_10.json.gz | Bin 0 -> 161 bytes Tests/app/data_seed/command_import_11.json.gz | Bin 0 -> 164 bytes Tests/app/data_seed/command_import_9.json.gz | Bin 0 -> 150 bytes 4 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 Tests/app/data_seed/command_import_10.json.gz create mode 100644 Tests/app/data_seed/command_import_11.json.gz create mode 100644 Tests/app/data_seed/command_import_9.json.gz diff --git a/Tests/Functional/Command/IndexImportCommandTest.php b/Tests/Functional/Command/IndexImportCommandTest.php index cd824d22..b7437419 100644 --- a/Tests/Functional/Command/IndexImportCommandTest.php +++ b/Tests/Functional/Command/IndexImportCommandTest.php @@ -85,37 +85,37 @@ public function testIndexImport(int $bulkSize, int $realSize, string $filename) * * @dataProvider compressedDataProvider */ -// public function testIndexImportWithGzipOption($bulkSize, $realSize, $filename) -// { -// $index = $this->getIndex(DummyDocument::class); -// -// $app = new Application(); -// $app->add($this->getImportCommand()); -// -// $command = $app->find('ongr:es:index:import'); -// $commandTester = new CommandTester($command); -// $commandTester->execute( -// [ -// 'command' => $command->getName(), -// 'filename' => __DIR__ . '/../../app/data_seed/' . $filename, -// '--bulk-size' => $bulkSize, -// '--gzip' => null, -// ] -// ); -// -// -// $search = $index->createSearch()->addQuery(new MatchAllQuery())->setSize($realSize); -// $results = $index->findDocuments($search); -// -// $ids = []; -// /** @var DummyDocument $doc */ -// foreach ($results as $doc) { -// $ids[] = (int)$doc->id; -// } -// sort($ids); -// $data = range(1, $realSize); -// $this->assertEquals($data, $ids); -// } + public function testIndexImportWithGzipOption($bulkSize, $realSize, $filename) + { + $index = $this->getIndex(DummyDocument::class); + + $app = new Application(); + $app->add($this->getImportCommand()); + + $command = $app->find('ongr:es:index:import'); + $commandTester = new CommandTester($command); + $commandTester->execute( + [ + 'command' => $command->getName(), + 'filename' => __DIR__ . '/../../app/data_seed/' . $filename, + '--bulk-size' => $bulkSize, + '--gzip' => null, + ] + ); + + + $search = $index->createSearch()->addQuery(new MatchAllQuery())->setSize($realSize); + $results = $index->findDocuments($search); + + $ids = []; + /** @var DummyDocument $doc */ + foreach ($results as $doc) { + $ids[] = (int)$doc->id; + } + sort($ids); + $data = range(1, $realSize); + $this->assertEquals($data, $ids); + } /** * Returns import index command with assigned container. diff --git a/Tests/app/data_seed/command_import_10.json.gz b/Tests/app/data_seed/command_import_10.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..ab344b14e91872a20a9877f997bd420e657b0bb0 GIT binary patch literal 161 zcmV;S0ABweiwFqNm^oem17mM(ZDDR?UukV{Z*p{BF)%J_b8l_{h0!|>!yp&~;GI(- z&kT@|7jte=RSYykq&7$`Oi}LMC|mx;n=O5w{7_o&NV#qW!P&!HJ+3bVI2goVuHUpE z>?mt_p8<1D^|Ne6I~+IP5Z?&j65k5%iTA>H#CO8?#P`Av#1F!c#E-&H#81LI%MP>W PLOsgD?<;;hs}i zQ&X_Kam_8Fh{B;jO0bmJ72@uBbeU$lUFn(y8r+H literal 0 HcmV?d00001 From abb63426598d2f624a86107ace2dd55d875e48c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Wed, 5 Feb 2020 08:36:44 +0200 Subject: [PATCH 07/11] fix psr2 style issue --- Tests/Functional/Command/IndexExportCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Functional/Command/IndexExportCommandTest.php b/Tests/Functional/Command/IndexExportCommandTest.php index 8788e13a..6bc7e3e3 100644 --- a/Tests/Functional/Command/IndexExportCommandTest.php +++ b/Tests/Functional/Command/IndexExportCommandTest.php @@ -88,7 +88,7 @@ public function testIndexExport(array $options, array $expectedResults) ); $results = $this->parseResult(vfsStream::url('tmp/test.json'), count($expectedResults)); - usort($results, function ($a, $b){ + usort($results, function ($a, $b) { return (int)$a['_id'] <=> (int)$b['_id']; }); $this->assertEquals($expectedResults, $results); From 62bf57867ef6fd7b58273649ee986b30258b2ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Wed, 5 Feb 2020 08:51:46 +0200 Subject: [PATCH 08/11] update travis to use codecov instead of coveralls --- .travis.yml | 2 +- README.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd8b67b1..f88368aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,4 +23,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/README.md b/README.md index d08a3e5a..5663b7f5 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ is the preferred and recommended way to ask questions about ONGR bundles and lib [![Build Status](https://travis-ci.org/ongr-io/ElasticsearchBundle.svg?branch=master)](https://travis-ci.org/ongr-io/ElasticsearchBundle) [![Latest Stable Version](https://poser.pugx.org/ongr/elasticsearch-bundle/v/stable)](https://packagist.org/packages/ongr/elasticsearch-bundle) +[![codecov](https://codecov.io/gh/ongr-io/ElasticsearchBundle/branch/master/graph/badge.svg)](https://codecov.io/gh/ongr-io/ElasticsearchBundle) [![Total Downloads](https://poser.pugx.org/ongr/elasticsearch-bundle/downloads)](https://packagist.org/packages/ongr/elasticsearch-bundle) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ongr-io/ElasticsearchBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ongr-io/ElasticsearchBundle/?branch=master) @@ -32,7 +33,8 @@ is the preferred and recommended way to ask questions about ONGR bundles and lib | Elasticsearch version | ElasticsearchBundle version | | --------------------- | -------------------------------- | -| >= 6.0 | ~6.x | +| >= 7.0 | ~7.x | +| >= 6.0, < 7.0 | ~6.x | | >= 5.0, < 5.0 | ~5.x, ~6.x (indexes with 1 type) | | >= 2.0, < 5.0 | >=1.0, < 5.0 | | >= 1.0, < 2.0 | >= 0.10, < 1.0 | From 4f488357a77f99350e93a6536f97b708231e80da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Wed, 5 Feb 2020 18:53:47 +0200 Subject: [PATCH 09/11] added buy me a coffee button --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5663b7f5..1a65ee6e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ # ONGR Elasticsearch Bundle +[![Build Status](https://travis-ci.org/ongr-io/ElasticsearchBundle.svg?branch=master)](https://travis-ci.org/ongr-io/ElasticsearchBundle) +[![Latest Stable Version](https://poser.pugx.org/ongr/elasticsearch-bundle/v/stable)](https://packagist.org/packages/ongr/elasticsearch-bundle) +[![codecov](https://codecov.io/gh/ongr-io/ElasticsearchBundle/branch/master/graph/badge.svg)](https://codecov.io/gh/ongr-io/ElasticsearchBundle) +[![Total Downloads](https://poser.pugx.org/ongr/elasticsearch-bundle/downloads)](https://packagist.org/packages/ongr/elasticsearch-bundle) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ongr-io/ElasticsearchBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ongr-io/ElasticsearchBundle/?branch=master) + + Elasticsearch Bundle was created in order to serve the need for professional [Elasticsearch][1] integration with enterprise level Symfony applications. This bundle is: @@ -21,12 +28,9 @@ Technical goodies: If you need any help, [stack overflow][3] is the preferred way to get answers. is the preferred and recommended way to ask questions about ONGR bundles and libraries. +If you like this library, help me to develop it by buying a cup of coffee -[![Build Status](https://travis-ci.org/ongr-io/ElasticsearchBundle.svg?branch=master)](https://travis-ci.org/ongr-io/ElasticsearchBundle) -[![Latest Stable Version](https://poser.pugx.org/ongr/elasticsearch-bundle/v/stable)](https://packagist.org/packages/ongr/elasticsearch-bundle) -[![codecov](https://codecov.io/gh/ongr-io/ElasticsearchBundle/branch/master/graph/badge.svg)](https://codecov.io/gh/ongr-io/ElasticsearchBundle) -[![Total Downloads](https://poser.pugx.org/ongr/elasticsearch-bundle/downloads)](https://packagist.org/packages/ongr/elasticsearch-bundle) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ongr-io/ElasticsearchBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ongr-io/ElasticsearchBundle/?branch=master) +Buy Me A Coffee ## Version matrix From f5359012752aa2eefb2ce77e24832bc888c2d1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Wed, 5 Feb 2020 19:20:49 +0200 Subject: [PATCH 10/11] fix php 7.4 incompatibility issues --- Service/ExportService.php | 2 +- Service/ImportService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Service/ExportService.php b/Service/ExportService.php index fba2949f..6997a7e8 100644 --- a/Service/ExportService.php +++ b/Service/ExportService.php @@ -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; } From f3878398630460f44709fa6a94db2d58200a20f6 Mon Sep 17 00:00:00 2001 From: Petr Malina Date: Thu, 20 Feb 2020 12:59:57 +0100 Subject: [PATCH 11/11] https://github.com/ongr-io/ElasticsearchBundle/issues/920 --- DependencyInjection/Compiler/MappingPass.php | 25 +++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/DependencyInjection/Compiler/MappingPass.php b/DependencyInjection/Compiler/MappingPass.php index e0b8ee0f..4bdd3be9 100644 --- a/DependencyInjection/Compiler/MappingPass.php +++ b/DependencyInjection/Compiler/MappingPass.php @@ -75,14 +75,23 @@ private function handleDirectoryMapping(ContainerBuilder $container, string $dir $indexMetadata = $parser->getIndexMetadata($class); if (!empty($indexMetadata)) { - $indexMetadata['settings'] = array_filter(array_merge_recursive( - $indexMetadata['settings'] ?? [], - [ - 'number_of_replicas' => $document->numberOfReplicas, - 'number_of_shards' => $document->numberOfShards, - ], - $indexesOverride[$namespace]['settings'] ?? [] - )); + $indexMetadata['settings'] = array_filter( + array_replace_recursive( + $indexMetadata['settings'] ?? [], + [ + 'number_of_replicas' => $document->numberOfReplicas, + 'number_of_shards' => $document->numberOfShards, + ], + $indexesOverride[$namespace]['settings'] ?? [] + ), + function ($value) { + if (0 === $value) { + return true; + } + + return (bool)$value; + } + ); $indexSettings = new Definition( IndexSettings::class,