mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +00:00
Remove useless method in SearchEngineInterface
This commit is contained in:
@@ -369,16 +369,6 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
throw new RuntimeException('Elasticsearch engine currently does not support auto-complete.');
|
throw new RuntimeException('Elasticsearch engine currently does not support auto-complete.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function excerpt($query, $fields, \record_adapter $record, SearchEngineOptions $options = null)
|
|
||||||
{
|
|
||||||
//@todo implements
|
|
||||||
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@@ -182,17 +182,6 @@ interface SearchEngineInterface
|
|||||||
*/
|
*/
|
||||||
public function autocomplete($query, SearchEngineOptions $options);
|
public function autocomplete($query, SearchEngineOptions $options);
|
||||||
|
|
||||||
/**
|
|
||||||
* Highlight the fields of a record
|
|
||||||
*
|
|
||||||
* @param type $query
|
|
||||||
* @param type $fields
|
|
||||||
* @param \record_adapter $record
|
|
||||||
*
|
|
||||||
* @return array The array of highlighted fields
|
|
||||||
*/
|
|
||||||
public function excerpt($query, $fields, \record_adapter $record, SearchEngineOptions $options = null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the cache of the SE (if applicable)
|
* Reset the cache of the SE (if applicable)
|
||||||
*
|
*
|
||||||
|
@@ -246,24 +246,6 @@ SQL;
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($searchEngine instanceof SearchEngineInterface) {
|
|
||||||
$ret = $searchEngine->excerpt($highlight, $fields, $this->record, $options);
|
|
||||||
|
|
||||||
// sets highlighted value from search engine, highlighted values will now
|
|
||||||
// be surrounded by [[em]][[/em]] tags
|
|
||||||
if ($ret) {
|
|
||||||
foreach ($fields as $key => $value) {
|
|
||||||
if (!isset($ret[$key])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($ret[$key] as $metaId => $newValue) {
|
|
||||||
$fields[$key]['values'][$metaId]['value'] = $newValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -711,54 +711,6 @@ abstract class SearchEngineAbstractTest extends \PhraseanetAuthenticatedTestCase
|
|||||||
$this->assertEquals(1, $results->getTotal());
|
$this->assertEquals(1, $results->getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExcerptFromSimpleQuery()
|
|
||||||
{
|
|
||||||
$record = self::$DI['record_2'];
|
|
||||||
$query_string = 'boomboklot' . $record->get_record_id() . 'excerptSimpleQuery';
|
|
||||||
|
|
||||||
$this->editRecord($query_string, $record);
|
|
||||||
|
|
||||||
self::$searchEngine->addRecord($record);
|
|
||||||
$this->updateIndex();
|
|
||||||
|
|
||||||
self::$searchEngine->resetCache();
|
|
||||||
$results = self::$searchEngine->query($query_string, 0, 1, $this->options);
|
|
||||||
$fields = [];
|
|
||||||
$foundRecord = $results->getResults()->first();
|
|
||||||
|
|
||||||
$this->assertInstanceOf('\record_adapter', $foundRecord);
|
|
||||||
|
|
||||||
foreach ($foundRecord->get_caption()->get_fields() as $field) {
|
|
||||||
foreach ($field->get_values() as $metaId => $v) {
|
|
||||||
$values[$metaId] = [
|
|
||||||
'value' => $v->getValue(),
|
|
||||||
'from_thesaurus' => false,
|
|
||||||
'qjs' => null,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$fields[$field->get_name()] = [
|
|
||||||
'values' => $values,
|
|
||||||
'separator' => ';',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$found = false;
|
|
||||||
$highlightedValues = self::$searchEngine->excerpt($query_string, $fields, $foundRecord);
|
|
||||||
foreach ($highlightedValues as $fieldValues) {
|
|
||||||
foreach ($fieldValues as $metaId => $field) {
|
|
||||||
if (strpos($field, '[[em]]') !== false && strpos($field, '[[/em]]') !== false) {
|
|
||||||
$found = true;
|
|
||||||
break 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$found && count($highlightedValues) > 0) {
|
|
||||||
$this->fail('Unable to build the excerpt');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract public function initialize();
|
abstract public function initialize();
|
||||||
|
|
||||||
abstract public function testAutocomplete();
|
abstract public function testAutocomplete();
|
||||||
|
@@ -223,8 +223,6 @@ abstract class PhraseanetAuthenticatedWebTestCase extends \PhraseanetAuthenticat
|
|||||||
$searchEngine = $this->prophesize(SearchEngineInterface::class);
|
$searchEngine = $this->prophesize(SearchEngineInterface::class);
|
||||||
$searchEngine->query('', 0, Argument::any(), Argument::any())
|
$searchEngine->query('', 0, Argument::any(), Argument::any())
|
||||||
->willReturn($result);
|
->willReturn($result);
|
||||||
$searchEngine->excerpt(Argument::any(), Argument::any(), Argument::any(), Argument::any())
|
|
||||||
->willReturn([]);
|
|
||||||
|
|
||||||
$app['search_engine'] = $searchEngine->reveal();
|
$app['search_engine'] = $searchEngine->reveal();
|
||||||
return $app;
|
return $app;
|
||||||
|
Reference in New Issue
Block a user