Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9e4c710
TASK: Decouple the query from the request builder
dfeyer Jan 28, 2016
fed5699
MERGE: Merge branch 'master' into decouple-query-from-builder
kdambekalns Jun 30, 2016
ebed605
TASK: Code style cleanup
kdambekalns Jun 30, 2016
a8e5523
TASK: Add Objects.yaml configuration to use FilteredQuery by default
dfeyer Jul 11, 2016
e8643d1
Merge branch '2.0' into decouple-query-from-builder
dfeyer Jul 11, 2016
a070322
TASK: Fix broken unit tests
dfeyer Jul 11, 2016
336ad95
Merge branch 'master' into decouple-query-from-builder
dfeyer Aug 4, 2016
d8ddac1
TASK: Extract query and driver for Elastic v1
dfeyer Jan 31, 2017
e64213a
Merge branch '2.0' into Flowpack-decouple-query-from-builder
dfeyer Jan 31, 2017
0f11688
TASK: Cleanup NodeIndexer dependencies
dfeyer Jan 31, 2017
f6a0403
TASK: Better Interfaces and create dedicated drivers for Elastic 1.x …
dfeyer Feb 1, 2017
6b7d15b
TASK: Extend the FilteredQuery from Driver Version1 in Version2
dfeyer Feb 1, 2017
8fe6a00
TASK: Add AbstractIndexerDriver
dfeyer Feb 1, 2017
123e099
TASK: Better PHP doc in Elastic Drivers
dfeyer Feb 1, 2017
c536a67
TASK: Rename IndexManagementDriverInterface:actions to aliasActions
dfeyer Feb 1, 2017
95192f4
TASK: Rename IndexManagementDriverInterface:remove to deleteIndex
dfeyer Feb 1, 2017
8cf86ee
TASK: Add a section in the README about the Driver settings
dfeyer Feb 1, 2017
09fc49b
TASK: Fix styling issues
dfeyer Feb 1, 2017
c51fcfd
TASK: Rename DocumentDriverInterface::deleteByDocumentIdentifier
dfeyer Feb 1, 2017
36fb60f
BUGIFX: Bulk request must end with end of line caracter
dfeyer Feb 3, 2017
3056c07
TASK: Update documentation about custom index name
dfeyer Feb 3, 2017
1e1523c
[BUGFIX] Change wrong variable name
Nikdro Feb 4, 2017
88bbb31
TASK: Fix Unit tests by not expecting should/must_not term
daniellienert Feb 4, 2017
71eb4ae
TASK: Extract query request and configuration to Settings
dfeyer Feb 4, 2017
61e376e
TASK: Refactor IndexDriver interface
dfeyer Feb 4, 2017
1048dfd
TASK: Fix Functional Tests
daniellienert Feb 4, 2017
adabdc0
TASK: Fix ElasticSearchQueryBuilderTest
daniellienert Feb 8, 2017
d4465fc
TASK: Build test matrix for ES Version 1/2 vs PHP 5.6/7
daniellienert Feb 8, 2017
6b25b54
TASK: Let travis download the patches objectmanager
daniellienert Feb 8, 2017
7728716
TASK: Pin typo3cr-search to use version ~2.0.0
daniellienert Feb 8, 2017
e3f0c97
TASK: Refactor travis script / use if instead of variables
daniellienert Feb 8, 2017
f00a430
TASK: Refactor the object factory
daniellienert Feb 8, 2017
7045744
Merge remote-tracking branch 'origin/2.0' into decouple-query-from-bu…
dfeyer Feb 10, 2017
2955a67
TASK: Set correct dependencies to flowpack/elasticsearch and typo3/ty…
dfeyer Feb 10, 2017
ac669a1
TASK: Default driver must support Elastic 1.x
dfeyer Feb 10, 2017
7ad20a0
TASK: Cleanup use statement in QueryFactory
dfeyer Feb 10, 2017
8b5c0ef
TASK: Add a FunctionScoreQuery as alternative Query implementation
dfeyer Feb 10, 2017
ec88f8d
TASK: QueryBuilder must act as a proxy for the method of the Request …
dfeyer Feb 10, 2017
5e2bd33
TASK: Add missing check for removed and hidden nodes in Driver 2.x
dfeyer Feb 10, 2017
e5281f5
TASK: Fix CGL issues
dfeyer Feb 10, 2017
38f6931
TASK: Remove temporary ObjectManager fix
daniellienert Feb 15, 2017
efed6e2
TASK: Changes according to review
daniellienert Feb 16, 2017
d11662c
TASK: Clean up (mostly) use statements
kdambekalns Feb 16, 2017
a35c7e0
TASK: Tweak TravisCI setup a bit
kdambekalns Feb 16, 2017
764451d
TASK: Remove PHP 7.1 again (in .travis.yml, not targeted)
kdambekalns Feb 17, 2017
1b79d2b
TASK: Update documentation for 2.x configuration
kdambekalns Feb 17, 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
18 changes: 12 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,32 @@ language: php
matrix:
include:
- php: 7.0
env: ES=1
- php: 7.0
env: ES=2
- php: 5.6
env: ES=1
- php: 5.6
env: ES=2
sudo: false
before_install:
- export NEOS_TARGET_VERSION=2.3
- cd ..
- wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.5.zip && unzip elasticsearch-1.7.5.zip
- mv elasticsearch-1.7.5 elasticsearch
- if [ "$ES" = 1 ]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.5.zip && unzip elasticsearch-1.7.5.zip && mv elasticsearch-1.7.5 elasticsearch; fi
- if [ "$ES" = 2 ]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.4.3.zip && unzip elasticsearch-2.4.3.zip && mv elasticsearch-2.4.3 elasticsearch; fi
- cd elasticsearch
- bin/elasticsearch -d
- cd ..
- git clone https://github.com/neos/neos-base-distribution.git -b ${NEOS_TARGET_VERSION}
- cd neos-base-distribution
- composer require flowpack/elasticsearch-contentrepositoryadaptor
- composer require typo3/typo3cr-search
- composer require --no-update --no-interaction flowpack/elasticsearch-contentrepositoryadaptor
install:
- composer install
- composer install --no-interaction
- cd ..
- rm -rf neos-base-distribution/Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor
- mv Flowpack.ElasticSearch.ContentRepositoryAdaptor neos-base-distribution/Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor
- cd neos-base-distribution
script:
- bin/phpunit --colors -c Build/BuildEssentials/PhpUnit/UnitTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Unit
- bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional
- if [ "$ES" = 1 ]; then FLOW_CONTEXT="Testing/ElasticVersion1" bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional; fi
- if [ "$ES" = 2 ]; then FLOW_CONTEXT="Testing/ElasticVersion2" bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional; fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver;

/*
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

use Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient;
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\LoggerInterface;
use TYPO3\Flow\Annotations as Flow;

/**
* Abstract Elasticsearch driver
*/
abstract class AbstractDriver
{
/**
* @Flow\Inject
* @var ElasticSearchClient
*/
protected $searchClient;

/**
* @Flow\Inject
* @var LoggerInterface
*/
protected $logger;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver;

/*
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

use TYPO3\TYPO3CR\Domain\Model\NodeInterface;

/**
* Abstract Fulltext Indexer Driver
*/
abstract class AbstractIndexerDriver extends AbstractDriver
{
/**
* Whether the node is configured as fulltext root.
*
* @param NodeInterface $node
* @return boolean
*/
protected function isFulltextRoot(NodeInterface $node)
{
if ($node->getNodeType()->hasConfiguration('search')) {
$elasticSearchSettingsForNode = $node->getNodeType()->getConfiguration('search');
if (isset($elasticSearchSettingsForNode['fulltext']['isRoot']) && $elasticSearchSettingsForNode['fulltext']['isRoot'] === true) {
return true;
}
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
<?php
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver;

/*
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception;
use TYPO3\Eel\ProtectedContextAwareInterface;
use TYPO3\Flow\Utility\Arrays;

/**
* Abstract Elasticsearch Query
*/
abstract class AbstractQuery implements QueryInterface, \JsonSerializable, \ArrayAccess, ProtectedContextAwareInterface
{
/**
* The ElasticSearch request, as it is being built up.
*
* @var array
*/
protected $request = [];

/**
* These fields are not accepted in a count request and must therefore be removed before doing so
*
* @var array
*/
protected $unsupportedFieldsInCountRequest = [];

/**
* @param array $request
* @param array $unsupportedFieldsInCountRequest
*/
public function __construct(array $request, array $unsupportedFieldsInCountRequest)
{
$this->request = $request;
$this->unsupportedFieldsInCountRequest = $unsupportedFieldsInCountRequest;
}

/**
* Modify a part of the Elasticsearch Request denoted by $path, merging together
* the existing values and the passed-in values.
*
* @param string $path
* @param mixed $requestPart
* @return QueryInterface
*/
public function setByPath($path, $requestPart)
{
$valueAtPath = Arrays::getValueByPath($this->request, $path);
if (is_array($valueAtPath)) {
$result = Arrays::arrayMergeRecursiveOverrule($valueAtPath, $requestPart);
} else {
$result = $requestPart;
}

$this->request = Arrays::setValueByPath($this->request, $path, $result);

return $this;
}

/**
* {@inheritdoc}
*/
public function toArray()
{
return $this->prepareRequest();
}

/**
* {@inheritdoc}
*/
public function getRequestAsJson()
{
return json_encode($this);
}

/**
* {@inheritdoc}
*/
public function addSortFilter($configuration)
{
if (!isset($this->request['sort'])) {
$this->request['sort'] = [];
}
$this->request['sort'][] = $configuration;
}

/**
* {@inheritdoc}
*/
public function aggregation($name, array $aggregationDefinition, $parentPath = null)
{
if (!array_key_exists('aggregations', $this->request)) {
$this->request['aggregations'] = [];
}

if ($parentPath !== null) {
$this->addSubAggregation($parentPath, $name, $aggregationDefinition);
} else {
$this->request['aggregations'][$name] = $aggregationDefinition;
}
}

/**
* This is an low level method for internal usage.
*
* You can add a custom $aggregationConfiguration under a given $parentPath. The $parentPath foo.bar would
* insert your $aggregationConfiguration under
* $this->request['aggregations']['foo']['aggregations']['bar']['aggregations'][$name]
*
* @param $parentPath
* @param $name
* @param array $aggregationConfiguration
* @return QueryInterface
* @throws Exception\QueryBuildingException
*/
protected function addSubAggregation($parentPath, $name, $aggregationConfiguration)
{
// Find the parentPath
$path =& $this->request['aggregations'];

foreach (explode(".", $parentPath) as $subPart) {
if ($path == null || !array_key_exists($subPart, $path)) {
throw new Exception\QueryBuildingException("The parent path " . $subPart . " could not be found when adding a sub aggregation");
}
$path =& $path[$subPart]['aggregations'];
}

$path[$name] = $aggregationConfiguration;
}

/**
* {@inheritdoc}
*/
public function suggestions($name, array $suggestionDefinition)
{
if (!array_key_exists('suggest', $this->request)) {
$this->request['suggest'] = [];
}

$this->request['suggest'][$name] = $suggestionDefinition;
}

/**
* {@inheritdoc}
*/
public function highlight($fragmentSize, $fragmentCount = null)
{
if ($fragmentSize === false) {
// Highlighting is disabled.
unset($this->request['highlight']);
} else {
$this->request['highlight'] = [
'fields' => [
'__fulltext*' => [
'fragment_size' => $fragmentSize,
'no_match_size' => $fragmentSize,
'number_of_fragments' => $fragmentCount
]
]
];
}
}

/**
* {@inheritdoc}
*/
public function setValueByPath($path, $value)
{
$this->request = Arrays::setValueByPath($this->request, $path, $value);
}

/**
* {@inheritdoc}
*/
public function appendAtPath($path, array $data)
{
$currentElement =& $this->request;
foreach (explode('.', $path) as $pathPart) {
if (!isset($currentElement[$pathPart])) {
throw new Exception\QueryBuildingException('The element at path "' . $path . '" was not an array (failed at "' . $pathPart . '").', 1383716367);
}
$currentElement =& $currentElement[$pathPart];
}
$currentElement[] = $data;
}

/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->prepareRequest();
}

/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
$this->request[] = $value;
} else {
$this->request[$offset] = $value;
}
}

/**
* {@inheritdoc}
*/
public function offsetExists($offset)
{
return isset($this->request[$offset]);
}

/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
{
unset($this->request[$offset]);
}

/**
* {@inheritdoc}
*/
public function offsetGet($offset)
{
return isset($this->request[$offset]) ? $this->request[$offset] : null;
}

/**
* Prepare the final request array
*
* This method is useful if you extend the current query implementation.
*
* @return array
*/
protected function prepareRequest()
{
return $this->request;
}

/**
* All methods are considered safe
*
* @param string $methodName
* @return boolean
*/
public function allowsCallOfMethod($methodName)
{
return true;
}

/**
* @param array $request
*/
public function replaceRequest(array $request)
{
$this->request = $request;
}
}
Loading