Skip to content

Commit a19da10

Browse files
committed
Merge pull request #123 from dfeyer/task-call-getrequest
TASK: Call method getRequest to make it more easy to extend This change replace $this->request by $this->getRequest() call during request execution. This is useful when creating custom query builder integration that can modifiy the request before execution.
2 parents cd739c7 + 2df7cb2 commit a19da10

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Eel/ElasticSearchQueryBuilder.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,17 @@ public function getFullElasticSearchHitForNode(NodeInterface $node)
643643
*/
644644
public function fetch()
645645
{
646+
$request = $this->getRequest();
646647
$timeBefore = microtime(true);
647-
$response = $this->elasticSearchClient->getIndex()->request('GET', '/_search', array(), json_encode($this->request));
648+
$response = $this->elasticSearchClient->getIndex()->request('GET', '/_search', array(), json_encode($request));
648649
$timeAfterwards = microtime(true);
649650

650651
$this->result = $response->getTreatedContent();
651652

652653
$this->result['nodes'] = array();
653654
if ($this->logThisQuery === true) {
654655
$this->logger->log(sprintf('Query Log (%s): %s -- execution time: %s ms -- Limit: %s -- Number of results returned: %s -- Total Results: %s',
655-
$this->logMessage, json_encode($this->request), (($timeAfterwards - $timeBefore) * 1000), $this->limit, count($this->result['hits']['hits']), $this->result['hits']['total']), LOG_DEBUG);
656+
$this->logMessage, json_encode($request), (($timeAfterwards - $timeBefore) * 1000), $this->limit, count($this->result['hits']['hits']), $this->result['hits']['total']), LOG_DEBUG);
656657
}
657658
if (array_key_exists('hits', $this->result) && is_array($this->result['hits']) && count($this->result['hits']) > 0) {
658659
$this->result['nodes'] = $this->convertHitsToNodes($this->result['hits']);
@@ -684,7 +685,7 @@ public function execute()
684685
public function count()
685686
{
686687
$timeBefore = microtime(true);
687-
$request = $this->request;
688+
$request = $this->getRequest();
688689
foreach ($this->unsupportedFieldsInCountRequest as $field) {
689690
if (isset($request[$field])) {
690691
unset($request[$field]);
@@ -698,7 +699,7 @@ public function count()
698699
$count = $treatedContent['count'];
699700

700701
if ($this->logThisQuery === true) {
701-
$this->logger->log('Count Query Log (' . $this->logMessage . '): ' . json_encode($this->request) . ' -- execution time: ' . (($timeAfterwards - $timeBefore) * 1000) . ' ms -- Total Results: ' . $count, LOG_DEBUG);
702+
$this->logger->log('Count Query Log (' . $this->logMessage . '): ' . json_encode($request) . ' -- execution time: ' . (($timeAfterwards - $timeBefore) * 1000) . ' ms -- Total Results: ' . $count, LOG_DEBUG);
702703
}
703704

704705
return $count;

0 commit comments

Comments
 (0)