mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
- add timing debug, disable permalinks injection to es
This commit is contained in:
@@ -26,6 +26,7 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineResult;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Alchemy\Phrasea\Utilities\Stopwatch;
|
||||
use Closure;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Alchemy\Phrasea\Model\Entities\FeedEntry;
|
||||
@@ -331,18 +332,26 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
);
|
||||
}
|
||||
|
||||
public function queryraw($queryText, SearchEngineOptions $options = null)
|
||||
public function queryraw($queryText, SearchEngineOptions $options)
|
||||
{
|
||||
$options = $options ?: new SearchEngineOptions();
|
||||
$stopwatch = new Stopwatch("es");
|
||||
|
||||
$context = $this->context_factory->createContext($options);
|
||||
|
||||
/** @var QueryCompiler $query_compiler */
|
||||
$query_compiler = $this->app['query_compiler'];
|
||||
$queryAST = $query_compiler->parse($queryText)->dump();
|
||||
|
||||
$stopwatch->lap("query parse");
|
||||
|
||||
$queryCompiled = $query_compiler->compile($queryText, $context);
|
||||
|
||||
$stopwatch->lap("query compile");
|
||||
|
||||
$queryESLib = $this->createRecordQueryParams($queryCompiled, $options, null);
|
||||
|
||||
$stopwatch->lap("createRecordQueryParams");
|
||||
|
||||
// ask ES to return field _version (incremental version number of document)
|
||||
$queryESLib['body']['version'] = true;
|
||||
|
||||
@@ -352,13 +361,19 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
$queryESLib['body']['highlight'] = $this->buildHighlightRules($context);
|
||||
}
|
||||
|
||||
$stopwatch->lap("buildHighlightRules");
|
||||
|
||||
$aggs = $this->getAggregationQueryParams($options);
|
||||
if ($aggs) {
|
||||
$queryESLib['body']['aggs'] = $aggs;
|
||||
}
|
||||
|
||||
$stopwatch->lap("getAggregationQueryParams");
|
||||
|
||||
$res = $this->client->search($queryESLib);
|
||||
|
||||
$stopwatch->lap("es client search");
|
||||
|
||||
// return $res;
|
||||
|
||||
$results = [];
|
||||
@@ -366,15 +381,22 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
$results[] = $hit;
|
||||
}
|
||||
|
||||
$stopwatch->lap("copy hits to results");
|
||||
|
||||
/** @var FacetsResponse $facets */
|
||||
$facets = $this->facetsResponseFactory->__invoke($res);
|
||||
$facets = $this->facetsResponseFactory->__invoke($res)->toArray();
|
||||
|
||||
$stopwatch->lap("build facets");
|
||||
|
||||
$stopwatch->stop();
|
||||
|
||||
return [
|
||||
'__stopwatch__' => $stopwatch,
|
||||
'results' => $results,
|
||||
'took' => $res['took'], // duration
|
||||
'count' => count($res['hits']['hits']), // available
|
||||
'total' => $res['hits']['total'], // total
|
||||
'facets' => $facets->toArray()
|
||||
'facets' => $facets
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -46,6 +46,10 @@ SQL;
|
||||
$record = null;
|
||||
$pls = [];
|
||||
while ($subdef = $statement->fetch()) {
|
||||
/*
|
||||
* for now disable permalink fetch, since if permalink does not exists, it will
|
||||
* be created and it's very sloooow (btw: why ?)
|
||||
*
|
||||
// too bad : to get permalinks we must instantiate a recordadapter
|
||||
// btw : why the unique permalink is not stored in subdef table ???
|
||||
if($subdef['record_id'] !== $current_rid) {
|
||||
@@ -65,12 +69,17 @@ SQL;
|
||||
// cant get record ? ignore
|
||||
}
|
||||
}
|
||||
*/
|
||||
$name = $subdef['name'];
|
||||
$records[$subdef['record_id']]['subdefs'][$name] = array(
|
||||
'path' => $subdef['path'],
|
||||
'width' => $subdef['width'],
|
||||
'height' => $subdef['height'],
|
||||
/*
|
||||
* no permalinks for now
|
||||
*
|
||||
'permalink' => array_key_exists($name, $pls) ? $pls[$name] : null
|
||||
*/
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user