本文整理汇总了PHP中Elasticsearch\Client::indices方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::indices方法的具体用法?PHP Client::indices怎么用?PHP Client::indices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elasticsearch\Client
的用法示例。
在下文中一共展示了Client::indices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteIndex
private function deleteIndex()
{
try {
$this->client->indices()->delete(['index' => self::INDEX_NAME]);
} catch (\Exception $e) {
// Do nothing.
}
}
示例2: reindex
/**
* Create the synonyms index for a store id.
*
* @param integer $storeId Store id.
* @param string[] $synonyms Raw synonyms list.
* @param string[] $expansions Raw expansions list.
*
* @return void
*/
public function reindex($storeId, $synonyms, $expansions)
{
$indexIdentifier = ThesaurusIndex::INDEX_IDENTIER;
$indexName = $this->indexSettingsHelper->createIndexNameFromIdentifier($indexIdentifier, $storeId);
$indexAlias = $this->indexSettingsHelper->getIndexAliasFromIdentifier($indexIdentifier, $storeId);
$indexSettings = ['settings' => $this->getIndexSettings($synonyms, $expansions)];
$this->client->indices()->create(['index' => $indexName, 'body' => $indexSettings]);
$this->indexManager->proceedIndexInstall($indexName, $indexAlias);
$this->cacheHelper->cleanIndexCache(ThesaurusIndex::INDEX_IDENTIER, $storeId);
}
示例3: createIndex
public function createIndex($index, array $params = [])
{
try {
$this->clientTo->indices()->delete(['index' => $index]);
} catch (Missing404Exception $e) {
}
if ($params) {
$this->clientTo->indices()->create(['index' => $index, 'body' => $params]);
}
}
示例4: createIndex
/**
* Create the index.
*/
public function createIndex()
{
// Try to delete the index if it already exists.
try {
$this->client->indices()->delete(['index' => env('ES_INDEX')]);
} catch (\Exception $e) {
}
// Create the mapping
$params = ['index' => env('ES_INDEX'), 'body' => ['settings' => ['number_of_shards' => 1, 'number_of_replicas' => 0, 'analysis' => ['filter' => ['autocomplete_filter' => ['type' => 'ngram', 'min_gram' => 3, 'max_gram' => 20]], 'analyzer' => ['autocomplete' => ['type' => 'custom', 'tokenizer' => 'standard', 'filter' => ['lowercase', 'autocomplete_filter']]]]], 'mappings' => [$this->type => ['properties' => ['created_at' => ['type' => 'string', 'analyzer' => 'standard'], 'updated_at' => ['type' => 'string', 'analyzer' => 'standard'], 'filePath' => ['type' => 'string', 'analyzer' => 'standard'], 'filePath' => ['type' => 'string', 'analyzer' => 'standard'], 'fileName' => ['type' => 'string', 'analyzer' => 'standard'], 'fileUrl' => ['type' => 'string', 'analyzer' => 'standard'], 'scanId' => ['type' => 'string', 'analyzer' => 'standard'], 'mediaTypeId' => ['type' => 'string', 'analyzer' => 'standard'], 'media_typeId' => ['type' => 'string', 'analyzer' => 'standard'], 'mediaTypeName' => ['type' => 'string', 'analyzer' => 'standard'], 'scanCreated_at' => ['type' => 'string', 'analyzer' => 'standard'], 'scanUpdated_at' => ['type' => 'string', 'analyzer' => 'standard'], 'scanScanId' => ['type' => 'string', 'analyzer' => 'standard'], 'scanScanQuality' => ['type' => 'string', 'analyzer' => 'standard'], 'scanFileDirectory' => ['type' => 'string', 'analyzer' => 'standard'], 'scanLocation' => ['type' => 'string', 'analyzer' => 'standard'], 'scanScanTime' => ['type' => 'string', 'analyzer' => 'standard'], 'scanVoltage' => ['type' => 'string', 'analyzer' => 'standard'], 'scanVoxelSize' => ['type' => 'string', 'analyzer' => 'standard'], 'scanImageCount' => ['type' => 'integer'], 'scanCurrent' => ['type' => 'string', 'analyzer' => 'standard'], 'scanSequence' => ['type' => 'integer'], 'mediaTypeName' => ['type' => 'string', 'analyzer' => 'standard'], 'mediaTypeName' => ['type' => 'string', 'analyzer' => 'standard'], 'scanSpecimenId' => ['type' => 'integer'], 'scanMuseumId' => ['type' => 'integer'], 'scanAuthorId' => ['type' => 'integer', 'analyzer' => 'standard'], 'scanAnimalGroupId' => ['type' => 'integer'], 'scanSpecimenCreated_at' => ['type' => 'string', 'analyzer' => 'standard'], 'scanSpecimenUpdated_at' => ['type' => 'string', 'analyzer' => 'standard'], 'scanSpecimenSpecimenNumber' => ['type' => 'integer'], 'scanSpecimenSpeciesCommonName' => ['type' => 'string', 'analyzer' => 'autocomplete'], 'scanSpecimenSpeciesScientificName' => ['type' => 'string', 'analyzer' => 'autocomplete'], 'scanMuseumName' => ['type' => 'string', 'analyzer' => 'standard'], 'scanAuthorName' => ['type' => 'string', 'analyzer' => 'standard'], 'scanAnimal_grouId' => ['type' => 'integer'], 'scanAnimal_groupName' => ['type' => 'string', 'analyzer' => 'standard']]]]]];
$this->client->indices()->create($params);
}
示例5: updateMapping
/**
* Puts mapping into elasticsearch client.
*
* @param array $types Specific types to put.
* @param bool $ignoreConflicts Ignore elasticsearch merge conflicts.
*/
public function updateMapping(array $types = [], $ignoreConflicts = true)
{
$this->isReadOnly('Mapping update');
$params['index'] = $this->getIndexName();
if (empty($types)) {
$map = $this->getConfig()['mappings'];
foreach ($map as $bundle) {
if (strpos($bundle, ':')) {
$types[] = $bundle;
} else {
$bundleMappings = $this->getMetadataCollector()->getMappings([$bundle]);
foreach ($bundleMappings as $document) {
$types[] = $document['bundle'] . ':' . $document['class'];
}
}
}
}
foreach ($types as $type) {
try {
$mapping = $this->getMetadataCollector()->getClientMapping([$type]);
$type = $this->getMetadataCollector()->getDocumentType($type);
$params['type'] = $type;
$params['body'] = $mapping;
$params['ignore_conflicts'] = $ignoreConflicts;
$this->client->indices()->putMapping(array_filter($params));
} catch (\Exception $e) {
throw new \LogicException('Only the documents[] can be passed to the type update command. ' . 'Maybe you added only a bundle. Please check if a document is mapped in the manager.');
}
}
}
示例6: createIndex
public function createIndex($settings = null, $mappings = null)
{
// Assemble new index name
$nextIndexNumber = 1;
$lastIndexName = $this->getLastIndexName();
if (null != $lastIndexName) {
$lastIndexNameArr = explode('_', $lastIndexName);
$nextIndexNumber = array_pop($lastIndexNameArr) + 1;
}
$nextIndexName = $this->getIndexName() . '_' . date('Y') . '_' . $nextIndexNumber;
// Create new index
$params['index'] = $nextIndexName;
if (null != $settings) {
$params['body']['settings'] = $settings;
}
if (null != $mappings) {
$params['body']['mappings'] = $mappings;
}
$this->client->indices()->create($params);
// Update aliases
$params = [];
$params['body'] = ['actions' => [['add' => ['index' => $nextIndexName, 'alias' => $this->getIndexNameCurrent()]], ['add' => ['index' => $nextIndexName, 'alias' => $this->getIndexName()]]]];
if (null != $lastIndexName) {
array_unshift($params['body']['actions'], ['remove' => ['index' => $lastIndexName, 'alias' => $this->getIndexNameCurrent()]]);
}
$this->client->indices()->updateAliases($params);
return $nextIndexName;
}
示例7: getCutoffrequencyLimit
/**
* Count document into the index and then multiply it by the request cutoff frequency
* to compute an absolute cutoff frequency limit (max numbre of doc).
*
* @param RequestInterface $request The spellcheck request.
*
* @return int
*/
private function getCutoffrequencyLimit(RequestInterface $request)
{
$indexStatsResponse = $this->client->indices()->stats(['index' => $request->getIndex()]);
$indexStats = current($indexStatsResponse['indices']);
$totalIndexedDocs = $indexStats['total']['docs']['count'];
return $request->getCutoffFrequency() * $totalIndexedDocs;
}
示例8: updateMapping
/**
* Puts mapping into elasticsearch client.
*
* @param array $types Specific types to put.
*
* @return array
*/
public function updateMapping(array $types = [])
{
$this->isReadOnly('Mapping update');
$params['index'] = $this->getIndexName();
$params['types'] = array_keys($types);
$params['body'] = $types;
return $this->client->indices()->putMapping($params);
}
示例9: callClearWithNonExistingIndexIsOk
/**
* @test
*/
public function callClearWithNonExistingIndexIsOk()
{
$client = $this->createClient();
$serializer = $this->createSerializer();
$storage = $this->createStorage($client, $serializer);
self::$client->indices()->delete(['index' => self::$index]);
$storage->clear();
}
示例10: getMappings
/**
* Returns all of the mappings for the specified indices, and types.
*
* @param array $indices The indices to get mappings from. Defaults to all indices.
* @param array $types The types to get mappings for. Defaults to all types.
*
* @return array like [
* 'indexName' => [
* 'mappings' => [
* 'typeName' => [
* 'properties' => [
* 'fieldName' => [
* 'type' => (string)..
* ],
* ],
* ],
* ],
* ]...
* ];
*/
public function getMappings(array $indices = [], array $types = [])
{
//If no indices or types are specified return mappings for all indices and types.
if (empty($indices) && empty($types)) {
return $this->client()->indices()->getMapping();
}
return $this->client->indices()->getMapping(['index' => $indices, 'type' => $types]);
}
示例11: handle
/**
* Handle index creation command
*
* @param Client $client
* @param string $index
*/
public function handle(Client $client, $index, $type)
{
$config = $this->configurationRepository->get($index);
if ($this->isInvalid($config, $type)) {
throw new \InvalidArgumentException();
}
$client->indices()->putMapping(['index' => $index, 'type' => $type, 'body' => [$type => $config['mappings'][$type]]]);
}
示例12: getIndices
public function getIndices()
{
$indices = $this->client->indices()->get(['index' => $this->indexPrefix . '_syrup*']);
if (!empty($indices)) {
return array_keys($indices);
}
return [];
}
示例13: handle
/**
* Handle index creation command
*
* @param Client $client
* @param string $index
*/
public function handle(Client $client, $index)
{
$config = $this->configurationRepository->get($index);
if (null === $config) {
throw new \InvalidArgumentException();
}
$client->indices()->create(['index' => $index, 'body' => $config]);
}
示例14: handle
/**
* Handle index creation command
*
* @param Client $client
* @param string $index
*/
public function handle($client, $index)
{
$config = $this->configurationRepository->get($index);
if (null === $client || null === $config) {
throw new \InvalidArgumentException();
}
$client->indices()->putSettings(['index' => $index, 'body' => ['settings' => $this->extractSettings($config)]]);
}
示例15: setSetting
private function setSetting($name, $value)
{
$index = $this->options->getIndexName();
$params = array();
$params['index'] = $index;
$params['body'][$name] = $value;
$response = $this->client->indices()->putSettings($params);
return igorw\get_in($response, ['acknowledged']);
}