mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-23 03:56:11 +01:00
[TASK] Finetune so interface is not reliant for Elastica library
This commit is contained in:
parent
2d9062b6e3
commit
ab1b6b5da9
3 changed files with 18 additions and 15 deletions
|
@ -21,8 +21,6 @@ namespace Codappix\SearchCore\Connection;
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Elastica\Query;
|
||||
|
||||
/**
|
||||
* Defines interface for connections to storage backend for interacting with documents.
|
||||
*/
|
||||
|
@ -57,13 +55,13 @@ interface ConnectionInterface
|
|||
*/
|
||||
public function search(SearchRequestInterface $searchRequest): SearchResultInterface;
|
||||
|
||||
/**
|
||||
* Will delete the index / db of defined document type.
|
||||
*/
|
||||
public function deleteIndexByDocumentType(string $documentType);
|
||||
|
||||
/**
|
||||
* Will delete the whole index / db.
|
||||
*/
|
||||
public function deleteIndex();
|
||||
|
||||
/**
|
||||
* Will delete the index / db of defined document type.
|
||||
*/
|
||||
public function deleteIndexByQuery(Query $query);
|
||||
}
|
||||
|
|
|
@ -176,6 +176,18 @@ class Elasticsearch implements Singleton, ConnectionInterface
|
|||
$index->delete();
|
||||
}
|
||||
|
||||
public function deleteIndexByDocumentType(string $documentType)
|
||||
{
|
||||
$query = Query::create([
|
||||
'query' => [
|
||||
'term' => [
|
||||
'search_document_type' => $documentType
|
||||
]
|
||||
]
|
||||
]);
|
||||
$this->deleteIndexByQuery($query);
|
||||
}
|
||||
|
||||
public function deleteIndexByQuery(Query $query)
|
||||
{
|
||||
$index = $this->connection->getClient()->getIndex($this->indexFactory->getIndexName());
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Codappix\SearchCore\Domain\Index;
|
|||
use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
|
||||
use Codappix\SearchCore\Configuration\InvalidArgumentException;
|
||||
use Codappix\SearchCore\Connection\ConnectionInterface;
|
||||
use Elastica\Query;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
abstract class AbstractIndexer implements IndexerInterface
|
||||
|
@ -114,13 +113,7 @@ abstract class AbstractIndexer implements IndexerInterface
|
|||
public function deleteDocuments()
|
||||
{
|
||||
$this->logger->info('Start deletion of indexed documents.');
|
||||
$this->connection->deleteIndexByQuery(Query::create([
|
||||
'query' => [
|
||||
'term' => [
|
||||
'search_document_type' => $this->getDocumentName()
|
||||
]
|
||||
]
|
||||
]));
|
||||
$this->connection->deleteIndexByDocumentType($this->getDocumentName());
|
||||
$this->logger->info('Finish deletion.');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue