mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-25 23:56:11 +01:00
TASK: Just some very early notes, without claiming of completeness
This commit is contained in:
parent
884a39e3a0
commit
1c1295cacb
9 changed files with 26 additions and 24 deletions
|
@ -28,6 +28,8 @@ interface ConnectionInterface
|
||||||
/**
|
/**
|
||||||
* Will add a new document.
|
* Will add a new document.
|
||||||
*
|
*
|
||||||
|
* TODO: Should be addDocument
|
||||||
|
*
|
||||||
* @param string $documentType
|
* @param string $documentType
|
||||||
* @param array $document
|
* @param array $document
|
||||||
*
|
*
|
||||||
|
@ -48,6 +50,8 @@ interface ConnectionInterface
|
||||||
/**
|
/**
|
||||||
* Will update an existing document.
|
* Will update an existing document.
|
||||||
*
|
*
|
||||||
|
* TODO: updateDocument (what about batches? consistency)
|
||||||
|
*
|
||||||
* @param string $documentType
|
* @param string $documentType
|
||||||
* @param array $document
|
* @param array $document
|
||||||
*
|
*
|
||||||
|
@ -58,6 +62,8 @@ interface ConnectionInterface
|
||||||
/**
|
/**
|
||||||
* Will remove an existing document.
|
* Will remove an existing document.
|
||||||
*
|
*
|
||||||
|
* TODO: deleteDocument (what about batches? consistency)
|
||||||
|
*
|
||||||
* @param string $documentType
|
* @param string $documentType
|
||||||
* @param int $identifier
|
* @param int $identifier
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,6 +27,8 @@ use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
||||||
* The current connection to elasticsearch.
|
* The current connection to elasticsearch.
|
||||||
*
|
*
|
||||||
* Wrapper for Elastica\Client.
|
* Wrapper for Elastica\Client.
|
||||||
|
*
|
||||||
|
* TODO: Catch inner exception and throw general ones (at least in Connection-Namespace (not elastic specific))
|
||||||
*/
|
*/
|
||||||
class Connection implements Singleton
|
class Connection implements Singleton
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,16 +26,19 @@ namespace Leonmrni\SearchCore\Domain\Index;
|
||||||
interface IndexerInterface
|
interface IndexerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Index the index.
|
* Fetches all documents from the indexerService and pushes it to the connection.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function index();
|
public function index();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index a single record.
|
* Fetches a single document from the indexerService and pushes it to the connection.
|
||||||
|
*
|
||||||
|
* @param string $identifier identifier, the indexer needs to identify a single document
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
* TODO: is record the correct name? (minor)
|
||||||
*/
|
*/
|
||||||
public function indexRecord($identifier);
|
public function indexRecord($identifier);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ class SearchRequest implements SearchRequestInterface
|
||||||
*/
|
*/
|
||||||
public function getSearchTerm()
|
public function getSearchTerm()
|
||||||
{
|
{
|
||||||
|
//TODO: This seems to be connection specific
|
||||||
return '"' . $this->query . '"';
|
return '"' . $this->query . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,21 +35,6 @@ class SearchService
|
||||||
*/
|
*/
|
||||||
protected $connection;
|
protected $connection;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \TYPO3\CMS\Core\Log\Logger
|
|
||||||
*/
|
|
||||||
protected $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inject log manager to get concrete logger from it.
|
|
||||||
*
|
|
||||||
* @param \TYPO3\CMS\Core\Log\LogManager $logManager
|
|
||||||
*/
|
|
||||||
public function injectLogger(\TYPO3\CMS\Core\Log\LogManager $logManager)
|
|
||||||
{
|
|
||||||
$this->logger = $logManager->getLogger(__CLASS__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ConnectionInterface $connection
|
* @param ConnectionInterface $connection
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,6 +27,8 @@ use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
||||||
*
|
*
|
||||||
* This is the place to add mappings of further parts to adjust the data before
|
* This is the place to add mappings of further parts to adjust the data before
|
||||||
* sending ot to connection.
|
* sending ot to connection.
|
||||||
|
*
|
||||||
|
* TODO: Probably a candidate for deletion
|
||||||
*/
|
*/
|
||||||
class DataHandler implements Singleton
|
class DataHandler implements Singleton
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Tests\FunctionalTestCase as CoreTestCase;
|
||||||
* All functional tests should extend this base class.
|
* All functional tests should extend this base class.
|
||||||
*
|
*
|
||||||
* It will take care of leaving a clean environment for next test.
|
* It will take care of leaving a clean environment for next test.
|
||||||
|
* TODO: this is in reality an "elastica" abstract case - not search_core ;)
|
||||||
*/
|
*/
|
||||||
abstract class AbstractFunctionalTestCase extends CoreTestCase
|
abstract class AbstractFunctionalTestCase extends CoreTestCase
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,7 +76,7 @@ class DataHandlerTest extends AbstractFunctionalTestCase
|
||||||
$hook->processDatamap_afterDatabaseOperations('update', 'tt_content', 6, [], $dataHandler);
|
$hook->processDatamap_afterDatabaseOperations('update', 'tt_content', 6, [], $dataHandler);
|
||||||
|
|
||||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||||
$this->assertTrue($response->isOK());
|
$this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
|
||||||
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document was indexed.');
|
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document was indexed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class DataHandlerTest extends AbstractFunctionalTestCase
|
||||||
$hook->processCmdmap_deleteAction('tt_content', 6, [], false, $dataHandler);
|
$hook->processCmdmap_deleteAction('tt_content', 6, [], false, $dataHandler);
|
||||||
|
|
||||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||||
$this->assertTrue($response->isOK());
|
$this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
|
||||||
$this->assertSame($response->getData()['hits']['total'], 0, 'Not exactly 0 document was indexed.');
|
$this->assertSame($response->getData()['hits']['total'], 0, 'Not exactly 0 document was indexed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +99,11 @@ class DataHandlerTest extends AbstractFunctionalTestCase
|
||||||
* @test
|
* @test
|
||||||
* @expectedException \Elastica\Exception\ResponseException
|
* @expectedException \Elastica\Exception\ResponseException
|
||||||
*/
|
*/
|
||||||
public function someUnkownOperationDoesNotBreakSomething()
|
public function someUnknownOperationDoesNotBreakSomething()
|
||||||
{
|
{
|
||||||
$dataHandler = new CoreDataHandler();
|
$dataHandler = new CoreDataHandler();
|
||||||
$hook = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Hook::class);
|
$hook = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Hook::class);
|
||||||
|
//TODO: this test is senseless, checking an exception not correct, this operation should not do anything!
|
||||||
$hook->processDatamap_afterDatabaseOperations('something', 'tt_content', 6, [], $dataHandler);
|
$hook->processDatamap_afterDatabaseOperations('something', 'tt_content', 6, [], $dataHandler);
|
||||||
|
|
||||||
// Should trigger Exception
|
// Should trigger Exception
|
||||||
|
|
|
@ -49,7 +49,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
||||||
|
|
||||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||||
|
|
||||||
$this->assertTrue($response->isOK());
|
$this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
|
||||||
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document was indexed.');
|
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document was indexed.');
|
||||||
$this->assertArraySubset(
|
$this->assertArraySubset(
|
||||||
['_source' => ['header' => 'indexed content element']],
|
['_source' => ['header' => 'indexed content element']],
|
||||||
|
@ -72,9 +72,10 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO: this does not test the indexer, it tests the backend
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function canHandleExisingIndex()
|
public function canHandleExistingIndex()
|
||||||
{
|
{
|
||||||
$indexer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
$indexer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
||||||
->get(IndexerFactory::class)
|
->get(IndexerFactory::class)
|
||||||
|
@ -88,7 +89,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
||||||
|
|
||||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||||
|
|
||||||
$this->assertTrue($response->isOK());
|
$this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
|
||||||
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document was indexed.');
|
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document was indexed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
||||||
|
|
||||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||||
|
|
||||||
$this->assertTrue($response->isOK());
|
$this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
|
||||||
$this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 document was indexed.');
|
$this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 document was indexed.');
|
||||||
$this->assertArraySubset(
|
$this->assertArraySubset(
|
||||||
['_source' => ['header' => 'Also indexable record']],
|
['_source' => ['header' => 'Also indexable record']],
|
||||||
|
|
Loading…
Reference in a new issue