Class MappingGenerator
Create indexes and mappings for test cases.
Index definition files should return an array of indexes to create. Each index in the array should follow the form of
[
'name' => 'articles',
'mapping' => [...],
'settings' => [...],
]
The mapping
key should be compatible with Elasticsearch's
mapping API and Elastica.
The settings
key can contain Elastica compatible index creation
settings.
Namespace: Cake\ElasticSearch\TestSuite\Fixture
See: https://elastica.io/getting-started/storing-and-indexing-documents.html#define-mapping
See: https://elastica.io/getting-started/storing-and-indexing-documents.html#define-mapping
Property Summary
-
$connection protected
string
-
$file protected
string
Method Summary
-
__construct() public
Constructor
-
createIndex() protected
Create an index.
-
dropIndex() protected
Drop an index if it exists.
-
reload() public
Drop and re-create indexes defined in the mapping schema file.
Method Detail
__construct() ¶ public
__construct(string $file, string $connection)
Constructor
Parameters
-
string
$file The index definition file.
-
string
$connection The connection to put indexes into.
createIndex() ¶ protected
createIndex(Cake\ElasticSearch\Datasource\Connection $db, array $mapping): void
Create an index.
Parameters
-
Cake\ElasticSearch\Datasource\Connection
$db The connection.
-
array
$mapping The index mapping and settings.
Returns
void
dropIndex() ¶ protected
dropIndex(Cake\ElasticSearch\Datasource\Connection $db, string $name): void
Drop an index if it exists.
Parameters
-
Cake\ElasticSearch\Datasource\Connection
$db The connection.
-
string
$name The name of the index to drop.
Returns
void
reload() ¶ public
reload(array<string> $indexes = null): void
Drop and re-create indexes defined in the mapping schema file.
Parameters
-
array<string>
$indexes optional A subset of indexes to reload. Used for testing.
Returns
void