Doctrine integration refactoring, adds realtime index updates
This commit is contained in:
parent
09fe17d36b
commit
6fee4131f4
15 changed files with 508 additions and 58 deletions
39
TypeInspector.php
Normal file
39
TypeInspector.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle;
|
||||
|
||||
use Elastica_Type;
|
||||
|
||||
/**
|
||||
* Extracts the mapping fields from a type
|
||||
*
|
||||
* @author Thibault Duplessis <thibault.duplessis@gmail.com>
|
||||
*/
|
||||
class TypeInspector
|
||||
{
|
||||
/**
|
||||
* Gets the type mapping fields
|
||||
*
|
||||
* @param Elastica_Type $type
|
||||
* @return array list of fields names
|
||||
*/
|
||||
public function getMappingFieldsNames(Elastica_Type $type)
|
||||
{
|
||||
$mappings = $type->getMapping();
|
||||
// skip index and type name
|
||||
// < 0.16.0 has both index and type levels
|
||||
// >= 0.16.0 has only type level
|
||||
do {
|
||||
$mappings = reset($mappings);
|
||||
} while (is_array($mappings) && !isset($mappings['properties']));
|
||||
if (!isset($mappings['properties'])) {
|
||||
return array();
|
||||
}
|
||||
$mappings = $mappings['properties'];
|
||||
if (array_key_exists('__isInitialized__', $mappings)) {
|
||||
unset($mappings['__isInitialized__']);
|
||||
}
|
||||
|
||||
return array_keys($mappings);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue