本文整理汇总了PHP中Elastica\Index::getMapping方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::getMapping方法的具体用法?PHP Index::getMapping怎么用?PHP Index::getMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Index
的用法示例。
在下文中一共展示了Index::getMapping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMetaData
/**
* @return array
*/
public function getMetaData()
{
$metaData = [];
try {
$mapping = $this->index->getMapping();
if (isset($mapping['page']) && isset($mapping['page']['_meta'])) {
$metaData = $mapping['page']['_meta'];
}
} catch (ResponseException $e) {
// legal catch, if no mapping found (fresh installation etc) we still want to show empty meta data
}
return $metaData;
}
示例2: checkMapping
/**
* Check that the mapping returned from Elasticsearch is as we want it.
*
* @param array $requiredMappings the mappings we want
* @return bool is the mapping good enough for us?
*/
private function checkMapping($requiredMappings)
{
$actualMappings = $this->index->getMapping();
$this->output("\n");
$this->outputIndented("\tValidating mapping...");
if ($this->checkConfig($actualMappings, $requiredMappings)) {
$this->output("ok\n");
return true;
} else {
$this->output("different...");
return false;
}
}
示例3: copy
/**
* Copies type mappings and documents from an old index to a new index.
*
* @see \Elastica\Tool\CrossIndex::reindex()
*
* @param \Elastica\Index $oldIndex
* @param \Elastica\Index $newIndex
* @param array $options keys: CrossIndex::OPTION_* constants
*
* @return \Elastica\Index The new index object
*/
public static function copy(Index $oldIndex, Index $newIndex, array $options = array())
{
// normalize types to array of string
$types = array();
if (isset($options[self::OPTION_TYPE])) {
$types = $options[self::OPTION_TYPE];
$types = is_array($types) ? $types : array($types);
$types = array_map(function ($type) {
if ($type instanceof Type) {
$type = $type->getName();
}
return (string) $type;
}, $types);
}
// copy mapping
foreach ($oldIndex->getMapping() as $type => $mapping) {
if (!empty($types) && !in_array($type, $types, true)) {
continue;
}
$type = new Type($newIndex, $type);
$type->setMapping($mapping['properties']);
}
// copy documents
return self::reindex($oldIndex, $newIndex, $options);
}