Skip to content

Commit

Permalink
support Elasticsearch 7
Browse files Browse the repository at this point in the history
  • Loading branch information
othillo committed May 11, 2020
1 parent 87d9b3b commit 5b1823c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ php:
- 7.4

env:
- ELASTICSEARCH_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.8.deb
- ELASTICSEARCH_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-amd64.deb

before_install:
# Disable XDebug speed up test execution.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $ composer require broadway/read-model-elasticsearch

| Elasticsearch Version | broadway/read-model-elasticsearch version |
| --------------------- | ----------------------------------------- |
| 7 | 0.7 |
| 6 | 0.6 |
| 5 | 0.5 |
| 2 | 0.1 |
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"require": {
"php": ">=7.2",
"broadway/broadway": "^2.3.1",
"elasticsearch/elasticsearch": "^6.0"
"elasticsearch/elasticsearch": "^7.0"
},
"authors": [
{
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
version: '3.2'
services:
elasticsearch:
image: elasticsearch:6.8.8
image: elasticsearch:7.6.2
ports:
- "9200:9200"
environment:
- discovery.type=single-node
8 changes: 3 additions & 5 deletions src/ElasticSearchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,10 @@ public function createIndex(): bool
if (count($this->notAnalyzedFields)) {
$indexParams['body'] = [
'mappings' => [
$class => [
'_source' => [
'enabled' => true,
],
'properties' => $this->createNotAnalyzedFieldsMapping($this->notAnalyzedFields),
'_source' => [
'enabled' => true,
],
'properties' => $this->createNotAnalyzedFieldsMapping($this->notAnalyzedFields),
],
];
}
Expand Down
21 changes: 12 additions & 9 deletions test/ElasticSearchRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,18 @@ public function it_creates_an_index_with_non_analyzed_terms()
$this->client->cluster()->health(['index' => $index, 'wait_for_status' => 'yellow', 'timeout' => '10s']);
$mapping = $this->client->indices()->getMapping(['index' => $index]);

$this->assertArrayHasKey($index, $mapping);
$this->assertArrayHasKey($type, $mapping[$index]['mappings']);
$nonAnalyzedTerms = [];

foreach ($mapping[$index]['mappings'][$type]['properties'] as $key => $value) {
$nonAnalyzedTerms[] = $key;
}

$this->assertEquals([$nonAnalyzedTerm], $nonAnalyzedTerms);
$expectedMapping = [
'test_non_analyzed_index' => [
'mappings' => [
'properties' => [
'name' => [
'type' => 'keyword',
],
],
],
],
];
$this->assertEquals($expectedMapping, $mapping);
}

/**
Expand Down

0 comments on commit 5b1823c

Please sign in to comment.