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 all 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
23 changes: 17 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
sudo: false
sudo: true

language: php

services:
- elasticsearch

env:
global:
- JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre"
- JACKRABBIT_VERSION=2.12.0
- SYMFONY__PHPCR__TRANSPORT=doctrinedbal
- ES_VERSION="5.3.0"
- ES_DOWNLOAD_URL="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.zip"

cache:
directories:
Expand All @@ -19,8 +19,10 @@ matrix:
include:
- php: 5.5
env:
- SULU_VERSION="~1.5.1"
- SULU_VERSION="~1.5.3"
- COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction"
- ES_VERSION="2.4.4"
- ES_DOWNLOAD_URL="https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.zip"
- php: 7.0
env:
- COMPOSER_FLAGS="--prefer-dist --no-interaction"
Expand All @@ -29,10 +31,16 @@ matrix:
- php: 7.0
env:
- COMPOSER_FLAGS="--prefer-dist --no-interaction"
- SULU_VERSION="~1.5.1"
- SULU_VERSION="~1.5.3"
- SYMFONY__PHPCR__TRANSPORT=jackrabbit
addons:
apt:
packages:
- oracle-java8-installer

before_install:
# Container based PHP image ues PHP 5.6.5, once it will be upgraded sudo will be not necessary
- sudo apt-get install -y oracle-java8-set-default
- |
if [[ $SYMFONY__PHPCR__TRANSPORT = jackrabbit ]]; then
if [ ! -f downloads/jackrabbit-standalone-$JACKRABBIT_VERSION.jar ]; then
Expand All @@ -45,6 +53,9 @@ before_install:
- if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi
- phpenv config-add Tests/travis.php.ini
- composer self-update
- curl -L -o elasticsearch.zip ${ES_DOWNLOAD_URL}
- unzip elasticsearch.zip
- ./elasticsearch-*/bin/elasticsearch -d

install:
- travis_retry composer require sulu/sulu:$SULU_VERSION $COMPOSER_FLAGS
Expand Down
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ and code are not stable yet (pre 1.0).
* Composer
* PHP `^5.5 || ^7.0`
* Sulu `^1.5`
* Elasticsearch `^2.2`
* Elasticsearch `^2.2 || ^5.0`

For detailed requirements see [composer.json](https://github.com/sulu/SuluArticleBundle/blob/master/composer.json).

Expand Down
58 changes: 6 additions & 52 deletions Resources/doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,13 @@

## Install ElasticSearch

The sulu article bundle requires a running elasticsearch `^2.2`.
The sulu article bundle requires a running elasticsearch `^2.2` or `^5.0`.

## Install bundle over composer:
There is an different installation and configuration depending on which version of ElasticSearch you are using.

```bash
composer require sulu/article-bundle
```
If you use version `^2.2` read: [Installation for ElasticSearch 2.2](installation_es2.md)
else read: [Installation for ElasticSearch 5.0](installation_es5.md)

**Add bundle to AbstractKernel:**

```php
/* app/AbstractKernel.php */

new Sulu\Bundle\ArticleBundle\SuluArticleBundle(),
new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(),
```

## Configure the bundles:

```yml
# app/config/config.yml

sulu_route:
mappings:
Sulu\Bundle\ArticleBundle\Document\ArticleDocument:
generator: schema
options:
route_schema: /articles/{object.getTitle()}

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

ongr_elasticsearch:
connections:
default:
index_name: su_articles
live:
index_name: su_articles_live
managers:
default:
connection: default
mappings:
- SuluArticleBundle
live:
connection: live
mappings:
- SuluArticleBundle
```

## Configure the routing

Expand Down Expand Up @@ -137,3 +89,5 @@ sulu_article:
# Display tab 'all' in list view
display_tab_all: true
```


61 changes: 61 additions & 0 deletions Resources/doc/installation_es2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Installation


## Install ElasticSearch

The sulu article bundle requires a running elasticsearch `^2.2`.

## Install bundle over composer:

```bash
composer require ongr/elasticsearch-bundle:1.2.9
composer require sulu/article-bundle
```

**Add bundle to AbstractKernel:**

```php
/* app/AbstractKernel.php */

new Sulu\Bundle\ArticleBundle\SuluArticleBundle(),
new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(),
```

## Configure the bundles:

```yml
# app/config/config.yml

sulu_route:
mappings:
Sulu\Bundle\ArticleBundle\Document\ArticleDocument:
generator: schema
options:
route_schema: /articles/{object.getTitle()}

sulu_core:
content:
structure:
default_type:
article: "article_default"
paths:
article:
path: "%kernel.root_dir%/Resources/templates/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
```
Loading