Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ElasticSearch 5.0 added #151

Merged
merged 30 commits into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3d15e99
Changed all deprecated methods + changed composer dependency
Apr 19, 2017
6377f52
Fixed Repository -> Manager
Apr 19, 2017
01f5e61
Documentation update for ES 5.
Apr 19, 2017
04667c2
Code style fix
Apr 19, 2017
49b927d
Now testcase also working for other ES version
Apr 20, 2017
070c8a7
Codestyle fixes
Apr 20, 2017
c2c60d5
Updated 5.5 ES version
Apr 20, 2017
f163ee8
Updated ONGR version to minimal 1.2.9
Apr 20, 2017
88bfbca
Merge branch 'develop' into feature/elasticsearch-50
kleinkoerkamp Apr 20, 2017
c135764
Now making use of environment variable + updated travis
Apr 20, 2017
080a687
Updated travis config for correct handling ES 5.*
Apr 20, 2017
6f987b4
Now with semicolon
Apr 20, 2017
42a893a
ES installation for Travis to seperate file
Apr 20, 2017
c750ff6
Added echo for test
Apr 20, 2017
1145233
Updated permissions
Apr 20, 2017
3677810
Changed permission
Apr 20, 2017
c90048c
Updated permissions
Apr 20, 2017
ba5fcf2
Added extra fix for permissions
Apr 21, 2017
5aeef77
Simplified logic for es script
Apr 21, 2017
356b8b0
update sulu version for travis
Apr 21, 2017
b0050a9
Now back to only travis config file + ONGR DSL specific minimal version
Apr 21, 2017
5935d7e
ONGR ES minimal version
Apr 21, 2017
8735f9a
Removed unused line
Apr 21, 2017
5e99a98
Changed Installation of ES for travis
Apr 21, 2017
1ee0799
Fix sudo error
Apr 21, 2017
375c78b
Fix for travis
Apr 21, 2017
8ff40ed
Allowing sudo
Apr 21, 2017
156285a
Sort test fix, extra option needed for ES5
Apr 21, 2017
b80175a
Fixed test + updated docs
Apr 21, 2017
e69ccd2
Fixed comments on PR
Apr 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Content/ArticleDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

use ONGR\ElasticsearchBundle\Result\DocumentIterator;
use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchDSL\Query\BoolQuery;
use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery;
use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
use ONGR\ElasticsearchDSL\Query\TermQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
use ONGR\ElasticsearchDSL\Search;
use ONGR\ElasticsearchDSL\Sort\FieldSort;
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
Expand Down Expand Up @@ -249,7 +249,7 @@ private function getSearchResult(array $filters, $limit, $page, $pageSize, $loca
$this->appendSortBy($filters['sortBy'], $sortMethod, $search);
}

return $repository->execute($search);
return $repository->findDocuments($search);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Content/ArticleSelectionContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Sulu\Bundle\ArticleBundle\Content;

use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchDSL\Query\IdsQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery;
use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocumentInterface;
use Sulu\Bundle\ArticleBundle\Metadata\ArticleViewDocumentIdTrait;
use Sulu\Component\Content\Compat\PropertyInterface;
Expand Down Expand Up @@ -72,7 +72,7 @@ public function getContentData(PropertyInterface $property)

$result = [];
/** @var ArticleViewDocumentInterface $articleDocument */
foreach ($repository->execute($search) as $articleDocument) {
foreach ($repository->findDocuments($search) as $articleDocument) {
$result[array_search($articleDocument->getUuid(), $value, false)] = $articleDocument;
}

Expand Down
20 changes: 10 additions & 10 deletions Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
use FOS\RestBundle\Routing\ClassResourceInterface;
use JMS\Serializer\SerializationContext;
use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchDSL\Query\BoolQuery;
use ONGR\ElasticsearchDSL\Query\IdsQuery;
use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery;
use ONGR\ElasticsearchDSL\Query\FullText\MatchQuery;
use ONGR\ElasticsearchDSL\Query\FullText\MultiMatchQuery;
use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
use ONGR\ElasticsearchDSL\Query\MatchQuery;
use ONGR\ElasticsearchDSL\Query\MultiMatchQuery;
use ONGR\ElasticsearchDSL\Query\TermQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
use ONGR\ElasticsearchDSL\Sort\FieldSort;
use Sulu\Bundle\ArticleBundle\Admin\ArticleAdmin;
use Sulu\Bundle\ArticleBundle\Document\ArticleDocument;
Expand Down Expand Up @@ -154,7 +154,7 @@ public function cgetAction(Request $request)
$search->setFrom(($page - 1) * $limit);

$result = [];
foreach ($repository->execute($search) as $document) {
foreach ($repository->findDocuments($search) as $document) {
if (false !== ($index = array_search($document->getUuid(), $ids))) {
$result[$index] = $document;
} else {
Expand Down Expand Up @@ -185,7 +185,7 @@ public function cgetAction(Request $request)
/**
* Returns single article.
*
* @param string $uuid
* @param string $uuid
* @param Request $request
*
* @return Response
Expand Down Expand Up @@ -238,7 +238,7 @@ public function postAction(Request $request)
* Update articles.
*
* @param Request $request
* @param string $uuid
* @param string $uuid
*
* @return Response
*/
Expand Down Expand Up @@ -313,7 +313,7 @@ public function deleteAction($id)
*
* @Post("/articles/{uuid}")
*
* @param string $uuid
* @param string $uuid
* @param Request $request
*
* @return Response
Expand Down Expand Up @@ -380,7 +380,7 @@ public function getSecurityContext()
/**
* Persists the document using the given information.
*
* @param array $data
* @param array $data
* @param object $document
* @param string $locale
*
Expand Down
6 changes: 3 additions & 3 deletions Document/Index/ArticleIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
use ONGR\ElasticsearchDSL\Query\TermQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
use Sulu\Bundle\ArticleBundle\Document\ArticleDocument;
use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocument;
use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocumentInterface;
Expand Down Expand Up @@ -254,7 +254,7 @@ public function remove($document)
$search = $repository->createSearch()
->addQuery(new TermQuery('uuid', $document->getUuid()))
->setSize(1000);
foreach ($repository->execute($search) as $viewDocument) {
foreach ($repository->findDocuments($search) as $viewDocument) {
$this->manager->remove($viewDocument);
}
}
Expand All @@ -279,7 +279,7 @@ public function clear()
->setSize($pageSize);

do {
$result = $repository->execute($search);
$result = $repository->findDocuments($search);
foreach ($result as $document) {
$this->manager->remove($document);
}
Expand Down
11 changes: 6 additions & 5 deletions Markup/ArticleLinkProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Sulu\Bundle\ArticleBundle\Markup;

use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchDSL\Query\IdsQuery;
use ONGR\ElasticsearchDSL\Query\RangeQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\RangeQuery;
use ONGR\ElasticsearchDSL\Search;
use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocumentInterface;
use Sulu\Bundle\ArticleBundle\Document\Index\DocumentFactory;
Expand Down Expand Up @@ -42,9 +42,9 @@ class ArticleLinkProvider implements LinkProviderInterface
private $types;

/**
* @param Manager $manager
* @param Manager $manager
* @param DocumentFactory $documentFactory
* @param array $types
* @param array $types
*/
public function __construct(Manager $manager, DocumentFactory $documentFactory, array $types)
{
Expand Down Expand Up @@ -87,7 +87,8 @@ public function preload(array $hrefs, $locale, $published = true)
$search->addQuery(new RangeQuery('authored', ['lte' => 'now']));
}

$documents = $this->manager->execute([$this->documentFactory->getClass('article')], $search);
$repository = $this->manager->getRepository($this->documentFactory->getClass('article'));
$documents = $repository->findDocuments($search);

$result = [];
/** @var ArticleViewDocumentInterface $document */
Expand Down
11 changes: 4 additions & 7 deletions Resources/doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ sulu_core:
type: "article"

ongr_elasticsearch:
connections:
default:
index_name: su_articles
live:
index_name: su_articles_live
managers:
default:
connection: default
index:
index_name: su_articles
mappings:
- SuluArticleBundle
live:
connection: live
index:
index_name: su_articles_live
mappings:
- SuluArticleBundle
```
Expand Down
8 changes: 4 additions & 4 deletions Sitemap/ArticleSitemapProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchBundle\Service\Repository;
use ONGR\ElasticsearchDSL\Query\TermQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocumentInterface;
use Sulu\Bundle\ArticleBundle\Document\Index\DocumentFactoryInterface;
use Sulu\Bundle\WebsiteBundle\Sitemap\Sitemap;
Expand Down Expand Up @@ -72,11 +72,11 @@ public function build($page, $portalKey, $locale)
private function getBulk(Repository $repository, $from, $size)
{
$search = $repository->createSearch()
->addQuery(new TermQuery('seo.hide_in_sitemap', false))
->addQuery(new TermQuery('seo.hide_in_sitemap', 'false'))
->setFrom($from)
->setSize($size);

return $repository->execute($search);
return $repository->findDocuments($search);
}

/**
Expand All @@ -94,7 +94,7 @@ public function getMaxPage()
{
$repository = $this->manager->getRepository($this->documentFactory->getClass('article'));
$search = $repository->createSearch()
->addQuery(new TermQuery('seo.hide_in_sitemap', false));
->addQuery(new TermQuery('seo.hide_in_sitemap', 'false'));

return ceil($repository->count($search) / self::PAGE_SIZE);
}
Expand Down
4 changes: 2 additions & 2 deletions Teaser/ArticleTeaserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Sulu\Bundle\ArticleBundle\Teaser;

use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchDSL\Query\IdsQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery;
use Sulu\Bundle\ArticleBundle\Metadata\ArticleViewDocumentIdTrait;
use Sulu\Bundle\ContentBundle\Teaser\Configuration\TeaserConfiguration;
use Sulu\Bundle\ContentBundle\Teaser\Provider\TeaserProviderInterface;
Expand Down Expand Up @@ -88,7 +88,7 @@ public function find(array $ids, $locale)
$search->addQuery(new IdsQuery($articleIds));

$result = [];
foreach ($repository->execute($search) as $item) {
foreach ($repository->findDocuments($search) as $item) {
$excerpt = $item->getExcerpt();
$result[] = new Teaser(
$item->getUuid(),
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Content/ArticleSelectionContentTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchBundle\Service\Repository;
use ONGR\ElasticsearchDSL\Query\IdsQuery;
use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery;
use ONGR\ElasticsearchDSL\Search;
use Prophecy\Argument;
use Sulu\Bundle\ArticleBundle\Content\ArticleSelectionContentType;
Expand Down Expand Up @@ -64,7 +64,7 @@ function ($id) {
}
)
)->shouldBeCalled();
$repository->execute($search->reveal())->willReturn($articles);
$repository->findDocuments($search->reveal())->willReturn($articles);

$contentType = new ArticleSelectionContentType(
$manager->reveal(),
Expand Down
7 changes: 6 additions & 1 deletion Tests/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function registerContainerConfiguration(LoaderInterface $loader)
$loader->load(__DIR__ . '/config/versioning.yml');
}

$loader->load(__DIR__ . '/config/config.yml');
// If version is lower then 5.6 it is an testcase for elasticsearch 2.*, so different ONGR config is needed
if (phpversion() < 5.6) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be handled via a envorinment variable in travis.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wachterjohannes you're right i will fix this

$loader->load(__DIR__ . '/config/config_es2.yml');
} else {
$loader->load(__DIR__ . '/config/config.yml');
}
}
}
11 changes: 4 additions & 7 deletions Tests/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ sulu_core:
type: "article"

ongr_elasticsearch:
connections:
default:
index_name: su_articles_test
live:
index_name: su_articles_test_live
managers:
default:
connection: default
index:
index_name: su_articles_test
mappings:
- SuluArticleBundle
live:
connection: live
index:
index_name: su_articles_test_live
mappings:
- SuluArticleBundle
# Sulu Routing
Expand Down
37 changes: 37 additions & 0 deletions Tests/app/config/config_es2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Doctrine Configuration
doctrine:
dbal:
dbname: "su_articles_test"

sulu_core:
content:
structure:
default_type:
article: "default"
paths:
article:
path: "%kernel.root_dir%/Resources/articles"
type: "article"

ongr_elasticsearch:
connections:
default:
index_name: su_articles_test
live:
index_name: su_articles_test_live
managers:
default:
connection: default
mappings:
- SuluArticleBundle
live:
connection: live
mappings:
- SuluArticleBundle
# Sulu Routing
sulu_route:
mappings:
Sulu\Bundle\ArticleBundle\Document\ArticleDocument:
generator: schema
options:
route_schema: /articles/{object.getTitle()}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": "^5.5 || ^7.0",
"sulu/sulu": "^1.5.3 || dev-develop",
"ongr/elasticsearch-bundle": "~1.0"
"ongr/elasticsearch-bundle": "^1.2.9 || ~5.0"
},
"require-dev": {
"zendframework/zend-stdlib": "2.3.1 as 2.0.0rc5",
Expand Down