Skip to content

Commit ceea665

Browse files
authored
A small upgrade to the v6 (#868)
* remove collection * update composer dependencies * upgrade tests for v6 elastic * added app kernel auto loading for the tests * improve the container loading * add ignore for the test cache * introducing index annotation and service * introducing index configuration, still experimental * marking the deprecations * update index service by adding more functions * update changelog * expand event variables * mark deprecations * remove deprecated service naming, use namespaces instead * mark deprecations * update * file reader included * changed events and improved mapping pass * cleanup * introduce new metadata collector for the index * starto to work with the object conversion * make first test run * finished index document metadata loading and index service loading * making dependency injection layer for the bundle more stable * index creation * index creation with analysis data works * simple document insert and find works * add more test cases to test iteration and find methods * introduce custom normalizer to support embedded objects in the document * added embedded objects lazy loading * make almost everything working again * fixed code style issues * add clover coverage to the ignore list * missing trailing slash in the beginning * update travis build requirement for version matrix
1 parent 1ef8129 commit ceea665

File tree

124 files changed

+2710
-7769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2710
-7769
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<!-- Please describe your problem/feature request here. -->
22

33
<!--
4-
If you are creating a problem issue don't forget to include your code snippet that
5-
we could recreate problem. Please include:
6-
- Your PHP version
4+
If you are creating an issue because you got some error or smth,
5+
don't forget to include your code snippet that
6+
we could help us to recreate the problem.
7+
8+
Please include:
9+
- PHP version
710
- Elasticsearch version
811
- Bundle version
12+
- Symfony version
913
-->

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
/Tests/app/cache/
33
/Tests/app/logs/
44
/Tests/app/build/
5+
/var/cache/test
56
/phpunit.xml
67
/composer.lock
8+
/coverage.clover

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
sudo: false
22
language: php
33
php:
4-
- 7.0
54
- 7.1
65
- 7.2
6+
- 7.3
77
env:
88
global:
99
- ES_VERSION=6.2.3 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
1010
matrix:
11-
- SYMFONY="~3.5"
12-
- SYMFONY="^4.0"
11+
- SYMFONY="~3.4"
12+
- SYMFONY="^4.1"
1313
install:
1414
- wget ${ES_DOWNLOAD_URL}
1515
- tar -xzf elasticsearch-${ES_VERSION}.tar.gz
1616
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
1717
before_script:
18-
- composer require --no-update symfony/symfony:${SYMFONY}
18+
- composer require --no-update symfony/framework-bundle:${SYMFONY}
1919
- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH
2020
- composer install --no-interaction --prefer-dist
2121
script:
2222
- wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200
23-
- vendor/bin/phpunit --coverage-clover=coverage.clover
24-
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,Tests/app/ ./
23+
- vendor/bin/phpunit --coverage-clover=coverage.clover --testsuite=Functional
24+
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,Tests/app/,var/cache ./
2525
after_script:
2626
- travis_retry php vendor/bin/coveralls

Annotation/AbstractAnnotation.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the ONGR package.
5+
*
6+
* (c) NFQ Technologies UAB <info@nfq.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace ONGR\ElasticsearchBundle\Annotation;
13+
14+
abstract class AbstractAnnotation
15+
{
16+
public $settings = [];
17+
18+
public function getSettings(): array
19+
{
20+
return $this->settings;
21+
}
22+
}

Annotation/Document.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

Annotation/Embedded.php

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111

1212
namespace ONGR\ElasticsearchBundle\Annotation;
1313

14-
use ONGR\ElasticsearchBundle\Mapping\Caser;
15-
1614
/**
17-
* Annotation for property which points to inner object.
18-
*
1915
* @Annotation
2016
* @Target("PROPERTY")
2117
*/
22-
final class Embedded
18+
final class Embedded extends AbstractAnnotation implements PropertiesAwareInterface
2319
{
20+
use NameAwareTrait;
21+
2422
/**
2523
* Inner object class name.
2624
*
@@ -29,54 +27,4 @@ final class Embedded
2927
* @Doctrine\Common\Annotations\Annotation\Required
3028
*/
3129
public $class;
32-
33-
/**
34-
* Name of the type field. Defaults to normalized property name.
35-
*
36-
* @var string
37-
*/
38-
public $name;
39-
40-
/**
41-
* Defines if related value will store a single object or an array of objects
42-
*
43-
* If this value is set to true, in the result ObjectIterator will be provided,
44-
* otherwise you will get single object.
45-
*
46-
* @var bool Object or ObjectIterator
47-
*/
48-
public $multiple;
49-
50-
/**
51-
* In this field you can define options.
52-
*
53-
* @var array
54-
*/
55-
public $options;
56-
57-
/**
58-
* {@inheritdoc}
59-
*/
60-
public function dump(array $exclude = [])
61-
{
62-
$array = array_diff_key(
63-
array_filter(
64-
get_object_vars($this),
65-
function ($value) {
66-
return $value || is_bool($value);
67-
}
68-
),
69-
array_flip(array_merge(['class', 'name', 'multiple'], $exclude))
70-
);
71-
72-
return array_combine(
73-
array_map(
74-
function ($key) {
75-
return Caser::snake($key);
76-
},
77-
array_keys($array)
78-
),
79-
array_values($array)
80-
);
81-
}
8230
}

Annotation/HashMap.php

Lines changed: 0 additions & 71 deletions
This file was deleted.

Annotation/Id.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,12 @@
1717
* @Annotation
1818
* @Target("PROPERTY")
1919
*/
20-
final class Id implements MetaField
20+
final class Id extends AbstractAnnotation implements MetaFieldInterface, PropertiesAwareInterface
2121
{
2222
const NAME = '_id';
2323

24-
/**
25-
* {@inheritdoc}
26-
*/
27-
public function getName()
24+
public function getName(): ?string
2825
{
2926
return self::NAME;
3027
}
31-
32-
/**
33-
* {@inheritdoc}
34-
*/
35-
public function getSettings()
36-
{
37-
return [];
38-
}
3928
}

Annotation/Index.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the ONGR package.
5+
*
6+
* (c) NFQ Technologies UAB <info@nfq.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace ONGR\ElasticsearchBundle\Annotation;
13+
14+
use Doctrine\Common\Annotations\Annotation\Attributes;
15+
16+
/**
17+
* Annotation to mark a class as an Elasticsearch index.
18+
*
19+
* @Annotation
20+
* @Target("CLASS")
21+
*/
22+
final class Index extends AbstractAnnotation
23+
{
24+
/**
25+
* Index alias name. By default the index name will be created with the timestamp appended to the alias.
26+
*/
27+
public $alias;
28+
29+
/**
30+
* Index alias name. By default the index name will be created with the timestamp appended to the alias.
31+
*/
32+
public $hosts = [
33+
'127.0.0.1:9200'
34+
];
35+
36+
public $numberOfShards = 5;
37+
38+
public $numberOfReplicas = 1;
39+
public $refreshInterval = 1;
40+
41+
/**
42+
* We strongly recommend to not use this parameter in the index annotation. By default it will be set as `_doc`
43+
* type name. Eventually it will be removed.
44+
*
45+
* @deprecated will be removed in v7 since there will be no more types in the indexes.
46+
*/
47+
public $typeName = '_doc';
48+
49+
/**
50+
* You can select one of your indexes to be default. Useful for cli commands when you don't
51+
* need to define an alias name. If default is not set the first index found will be set as default one.
52+
*/
53+
public $default = false;
54+
}

Annotation/MetaField.php renamed to Annotation/MetaFieldInterface.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@
1414
/**
1515
* All meta-field annotations must implement this interface.
1616
*/
17-
interface MetaField
17+
interface MetaFieldInterface
1818
{
19-
/**
20-
* Returns meta-field name.
21-
*
22-
* @return string
23-
*/
24-
public function getName();
25-
26-
/**
27-
* Returns meta-field settings.
28-
*
29-
* @return array
30-
*/
31-
public function getSettings();
3219
}

0 commit comments

Comments
 (0)