mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 09:16:21 +01:00
TASK: Resolve first review results
* Also remove coverage output on stdout, as it won't help anyone.
This commit is contained in:
parent
1c1295cacb
commit
98affa8f69
10 changed files with 24 additions and 35 deletions
|
@ -50,6 +50,6 @@ class IndexCommandController extends CommandController
|
|||
{
|
||||
// TODO: Allow to index multiple tables at once?
|
||||
// TODO: Also allow to index everything?
|
||||
$this->indexerFactory->getIndexer($table)->index();
|
||||
$this->indexerFactory->getIndexer($table)->indexAllDocuments();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,12 @@ interface ConnectionInterface
|
|||
/**
|
||||
* Will add a new document.
|
||||
*
|
||||
* TODO: Should be addDocument
|
||||
*
|
||||
* @param string $documentType
|
||||
* @param array $document
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($documentType, array $document);
|
||||
public function addDocument($documentType, array $document);
|
||||
|
||||
/**
|
||||
* Add the given documents.
|
||||
|
@ -50,26 +48,26 @@ interface ConnectionInterface
|
|||
/**
|
||||
* Will update an existing document.
|
||||
*
|
||||
* TODO: updateDocument (what about batches? consistency)
|
||||
* NOTE: Batch updating is not yet supported.
|
||||
*
|
||||
* @param string $documentType
|
||||
* @param array $document
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function update($documentType, array $document);
|
||||
public function updateDocument($documentType, array $document);
|
||||
|
||||
/**
|
||||
* Will remove an existing document.
|
||||
*
|
||||
* TODO: deleteDocument (what about batches? consistency)
|
||||
* NOTE: Batch deleting is not yet supported.
|
||||
*
|
||||
* @param string $documentType
|
||||
* @param int $identifier
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete($documentType, $identifier);
|
||||
public function deleteDocument($documentType, $identifier);
|
||||
|
||||
/**
|
||||
* Search by given request and return result.
|
||||
|
|
|
@ -80,7 +80,7 @@ class Elasticsearch implements Singleton, ConnectionInterface
|
|||
$this->documentFactory = $documentFactory;
|
||||
}
|
||||
|
||||
public function add($documentType, array $document)
|
||||
public function addDocument($documentType, array $document)
|
||||
{
|
||||
$this->withType(
|
||||
$documentType,
|
||||
|
@ -90,7 +90,7 @@ class Elasticsearch implements Singleton, ConnectionInterface
|
|||
);
|
||||
}
|
||||
|
||||
public function delete($documentType, $identifier)
|
||||
public function deleteDocument($documentType, $identifier)
|
||||
{
|
||||
$this->withType(
|
||||
$documentType,
|
||||
|
@ -100,7 +100,7 @@ class Elasticsearch implements Singleton, ConnectionInterface
|
|||
);
|
||||
}
|
||||
|
||||
public function update($documentType, array $document)
|
||||
public function updateDocument($documentType, array $document)
|
||||
{
|
||||
$this->withType(
|
||||
$documentType,
|
||||
|
@ -110,12 +110,6 @@ class Elasticsearch implements Singleton, ConnectionInterface
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given documents to elasticsearch.
|
||||
*
|
||||
* @param string $documentType
|
||||
* @param array $documents
|
||||
*/
|
||||
public function addDocuments($documentType, array $documents)
|
||||
{
|
||||
$this->withType(
|
||||
|
@ -141,6 +135,7 @@ class Elasticsearch implements Singleton, ConnectionInterface
|
|||
|
||||
/**
|
||||
* @param SearchRequestInterface $searchRequest
|
||||
*
|
||||
* @return \Elastica\ResultSet
|
||||
*/
|
||||
public function search(SearchRequestInterface $searchRequest)
|
||||
|
@ -152,7 +147,7 @@ class Elasticsearch implements Singleton, ConnectionInterface
|
|||
|
||||
// TODO: Return wrapped result to implement our interface.
|
||||
// Also update php doc to reflect the change.
|
||||
return $search->search($searchRequest->getSearchTerm());
|
||||
return $search->search('"' . $searchRequest->getSearchTerm() . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ interface IndexerInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index();
|
||||
public function indexAllDocuments();
|
||||
|
||||
/**
|
||||
* Fetches a single document from the indexerService and pushes it to the connection.
|
||||
|
@ -38,7 +38,6 @@ interface IndexerInterface
|
|||
* @param string $identifier identifier, the indexer needs to identify a single document
|
||||
*
|
||||
* @return void
|
||||
* TODO: is record the correct name? (minor)
|
||||
*/
|
||||
public function indexRecord($identifier);
|
||||
public function indexDocument($identifier);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class TcaIndexer implements IndexerInterface
|
|||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function index()
|
||||
public function indexAllDocuments()
|
||||
{
|
||||
$this->logger->info('Start indexing');
|
||||
foreach ($this->getRecordGenerator() as $records) {
|
||||
|
@ -79,10 +79,10 @@ class TcaIndexer implements IndexerInterface
|
|||
$this->logger->info('Finish indexing');
|
||||
}
|
||||
|
||||
public function indexRecord($identifier)
|
||||
public function indexDocument($identifier)
|
||||
{
|
||||
$this->logger->info('Start indexing single record.', [$identifier]);
|
||||
$this->connection->add($this->tcaTableService->getTableName(), $this->getRecord($identifier));
|
||||
$this->connection->addDocument($this->tcaTableService->getTableName(), $this->getRecord($identifier));
|
||||
$this->logger->info('Finish indexing');
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ class SearchRequest implements SearchRequestInterface
|
|||
*/
|
||||
public function getSearchTerm()
|
||||
{
|
||||
//TODO: This seems to be connection specific
|
||||
return '"' . $this->query . '"';
|
||||
return $this->query;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class DataHandler implements Singleton
|
|||
public function add($table, array $record)
|
||||
{
|
||||
$this->logger->debug('Record received for add.', [$table, $record]);
|
||||
$this->indexerFactory->getIndexer($table)->indexRecord($record['uid']);
|
||||
$this->indexerFactory->getIndexer($table)->indexDocument($record['uid']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +75,7 @@ class DataHandler implements Singleton
|
|||
public function update($table, array $record)
|
||||
{
|
||||
$this->logger->debug('Record received for update.', [$table, $record]);
|
||||
$this->indexerFactory->getIndexer($table)->indexRecord($record['uid']);
|
||||
$this->indexerFactory->getIndexer($table)->indexDocument($record['uid']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,6 +85,6 @@ class DataHandler implements Singleton
|
|||
public function delete($table, $identifier)
|
||||
{
|
||||
$this->logger->debug('Record received for delete.', [$table, $identifier]);
|
||||
$this->connection->delete($table, $identifier);
|
||||
$this->connection->deleteDocument($table, $identifier);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,5 @@
|
|||
<logging>
|
||||
<log type="coverage-html" target="../../.Build/report/functional/html" lowUpperBound="35" highLowerBound="70"/>
|
||||
<log type="coverage-clover" target="../../.Build/report/functional/clover/coverage"/>
|
||||
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
|
|
@ -44,7 +44,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
|||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
||||
->get(IndexerFactory::class)
|
||||
->getIndexer('tt_content')
|
||||
->index()
|
||||
->indexAllDocuments()
|
||||
;
|
||||
|
||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||
|
@ -82,10 +82,10 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
|||
->getIndexer('tt_content')
|
||||
;
|
||||
|
||||
$indexer->index();
|
||||
$indexer->indexAllDocuments();
|
||||
|
||||
// Index 2nd time, index already exists in elasticsearch.
|
||||
$indexer->index();
|
||||
$indexer->indexAllDocuments();
|
||||
|
||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||
|
||||
|
@ -104,7 +104,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
|||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
||||
->get(IndexerFactory::class)
|
||||
->getIndexer('tt_content')
|
||||
->index()
|
||||
->indexAllDocuments()
|
||||
;
|
||||
|
||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||
|
|
|
@ -29,6 +29,5 @@
|
|||
<logging>
|
||||
<log type="coverage-html" target="../../.Build/report/unit/html" lowUpperBound="35" highLowerBound="70"/>
|
||||
<log type="coverage-clover" target="../../.Build/report/unit/clover/coverage"/>
|
||||
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
|
Loading…
Reference in a new issue