Remove useless method in SearchEngineInterface

This commit is contained in:
Benoît Burnichon
2016-03-29 19:08:09 +02:00
parent 973826eeb3
commit 37883ed1ae
5 changed files with 0 additions and 89 deletions

View File

@@ -369,16 +369,6 @@ class ElasticSearchEngine implements SearchEngineInterface
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}
*/

View File

@@ -182,17 +182,6 @@ interface SearchEngineInterface
*/
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)
*

View File

@@ -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;
}

View File

@@ -711,54 +711,6 @@ abstract class SearchEngineAbstractTest extends \PhraseanetAuthenticatedTestCase
$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 testAutocomplete();

View File

@@ -223,8 +223,6 @@ abstract class PhraseanetAuthenticatedWebTestCase extends \PhraseanetAuthenticat
$searchEngine = $this->prophesize(SearchEngineInterface::class);
$searchEngine->query('', 0, Argument::any(), Argument::any())
->willReturn($result);
$searchEngine->excerpt(Argument::any(), Argument::any(), Argument::any(), Argument::any())
->willReturn([]);
$app['search_engine'] = $searchEngine->reveal();
return $app;