当前位置: 首页>>代码示例>>PHP>>正文


PHP Mapping::setParam方法代码示例

本文整理汇总了PHP中Elastica\Type\Mapping::setParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Mapping::setParam方法的具体用法?PHP Mapping::setParam怎么用?PHP Mapping::setParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Elastica\Type\Mapping的用法示例。


在下文中一共展示了Mapping::setParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * @return Status
  */
 public function validate()
 {
     $this->outputIndented("Validating mappings...");
     if ($this->optimizeIndexForExperimentalHighlighter && !in_array('experimental highlighter', $this->availablePlugins)) {
         $this->output("impossible!\n");
         return Status::newFatal(new RawMessage("wgCirrusSearchOptimizeIndexForExperimentalHighlighter is set to true but the " . "'experimental highlighter' plugin is not installed on all hosts."));
     }
     $requiredMappings = $this->mappingConfig;
     if (!$this->checkMapping($requiredMappings)) {
         /** @var Mapping[] $actions */
         $actions = array();
         // TODO Conflict resolution here might leave old portions of mappings
         foreach ($this->types as $typeName => $type) {
             $action = new Mapping($type);
             foreach ($requiredMappings[$typeName] as $key => $value) {
                 $action->setParam($key, $value);
             }
             $actions[] = $action;
         }
         try {
             foreach ($actions as $action) {
                 $action->send();
             }
             $this->output("corrected\n");
         } catch (ExceptionInterface $e) {
             $this->output("failed!\n");
             $message = ElasticsearchIntermediary::extractMessage($e);
             return Status::newFatal(new RawMessage("Couldn't update mappings.  Here is elasticsearch's error message: {$message}\n"));
         }
     }
     return Status::newGood();
 }
开发者ID:jamesmontalvo3,项目名称:mediawiki-extensions-CirrusSearch,代码行数:35,代码来源:MappingValidator.php

示例2: testParent

 public function testParent()
 {
     $index = $this->_createIndex();
     $typeBlog = new Type($index, 'blog');
     $typeComment = new Type($index, 'comment');
     $mapping = new Mapping();
     $mapping->setParam('_parent', array('type' => 'blog'));
     $typeComment->setMapping($mapping);
     $entry1 = new Document(1);
     $entry1->set('title', 'Hello world');
     $typeBlog->addDocument($entry1);
     $entry2 = new Document(2);
     $entry2->set('title', 'Foo bar');
     $typeBlog->addDocument($entry2);
     $entry3 = new Document(3);
     $entry3->set('title', 'Till dawn');
     $typeBlog->addDocument($entry3);
     $comment = new Document(1);
     $comment->set('author', 'Max');
     $comment->setParent(2);
     // Entry Foo bar
     $typeComment->addDocument($comment);
     $index->optimize();
     $query = new HasChild('Max', 'comment');
     $resultSet = $typeBlog->search($query);
     $this->assertEquals(1, $resultSet->count());
     $this->assertEquals(array('title' => 'Foo bar'), $resultSet->current()->getData());
 }
开发者ID:kskod,项目名称:Elastica,代码行数:28,代码来源:IndexTest.php

示例3: validate

 /**
  * @return Status
  */
 public function validate()
 {
     $this->outputIndented("Validating mappings...");
     if ($this->optimizeIndexForExperimentalHighlighter && !in_array('experimental highlighter', $this->availablePlugins)) {
         $this->output("impossible!\n");
         return Status::newFatal(new RawMessage("wgCirrusSearchOptimizeIndexForExperimentalHighlighter is set to true but the " . "'experimental highlighter' plugin is not installed on all hosts."));
     }
     $requiredMappings = $this->mappingConfig;
     if (!$this->checkMapping($requiredMappings)) {
         /** @var Mapping[] $actions */
         $actions = array();
         // TODO Conflict resolution here might leave old portions of mappings
         foreach ($this->types as $typeName => $type) {
             $action = new Mapping($type);
             foreach ($requiredMappings[$typeName] as $key => $value) {
                 $action->setParam($key, $value);
             }
             $actions[] = $action;
         }
         try {
             // @todo Use $action->send(array('master_timeout' => ...))
             // after updating to version of Elastica library that supports it.
             // See https://github.com/ruflin/Elastica/pull/1004
             foreach ($actions as $action) {
                 $action->getType()->request('_mapping', Request::PUT, $action->toArray(), array('master_timeout' => $this->masterTimeout));
             }
             $this->output("corrected\n");
         } catch (ExceptionInterface $e) {
             $this->output("failed!\n");
             $message = ElasticsearchIntermediary::extractMessage($e);
             return Status::newFatal(new RawMessage("Couldn't update mappings.  Here is elasticsearch's error message: {$message}\n"));
         }
     }
     return Status::newGood();
 }
开发者ID:zoglun,项目名称:mediawiki-extensions-CirrusSearch,代码行数:38,代码来源:MappingValidator.php

示例4: getElasticaMapping

 /**
  * @return \Elastica\Type\Mapping
  */
 public function getElasticaMapping()
 {
     $mapping = new Mapping();
     $mapping->setProperties($this->getElasticaFields());
     $mapping->setParam('date_detection', false);
     return $mapping;
 }
开发者ID:ajshort,项目名称:silverstripe-elastica,代码行数:10,代码来源:Searchable.php

示例5: sendMapping

 /**
  * @param \Elastica\Index $index
  * @param string $mappingName
  * @param array $mappingData
  *
  * @return void
  */
 protected function sendMapping(Index $index, $mappingName, array $mappingData)
 {
     $type = $index->getType($mappingName);
     $this->messenger->info(sprintf('Send mapping type "%s" (index: "%s")', $mappingName, $index->getName()));
     $mapping = new Mapping($type);
     foreach ($mappingData as $key => $value) {
         $mapping->setParam($key, $value);
     }
     $mapping->send();
 }
开发者ID:spryker,项目名称:Search,代码行数:17,代码来源:IndexInstaller.php

示例6: testParentMapping

 public function testParentMapping()
 {
     $index = $this->_createIndex();
     $parenttype = new Type($index, 'parenttype');
     $parentmapping = new Mapping($parenttype, array('name' => array('type' => 'string', 'store' => 'yes')));
     $parenttype->setMapping($parentmapping);
     $childtype = new Type($index, 'childtype');
     $childmapping = new Mapping($childtype, array('name' => array('type' => 'string', 'store' => 'yes')));
     $childmapping->setParam('_parent', array('type' => 'parenttype'));
     $childtype->setMapping($childmapping);
 }
开发者ID:kskod,项目名称:Elastica,代码行数:11,代码来源:MappingTest.php

示例7: create

 /**
  * @param Schema $schema
  * @param string $defaultAnalyzer
  * @return Mapping
  */
 public function create(Schema $schema, $defaultAnalyzer = null)
 {
     $this->defaultAnalyzer = $defaultAnalyzer;
     $rootObject = new \stdClass();
     $rootObject->dynamic_templates = [];
     $mapping = new Mapping(null, $this->mapSchema($schema, $rootObject));
     foreach (get_object_vars($rootObject) as $k => $v) {
         if (!empty($v)) {
             $mapping->setParam($k, $v);
         }
     }
     return $mapping;
 }
开发者ID:gdbots,项目名称:pbj-php,代码行数:18,代码来源:MappingFactory.php

示例8: createType

 /**
  * {@inheritDoc}
  */
 public function createType(ClassMetadata $metadata)
 {
     $type = $this->getIndex($metadata->index)->getType($metadata->type);
     $properties = $this->getMapping($metadata->fieldMappings);
     $rootProperties = $this->getRootMapping($metadata->rootMappings);
     $mapping = new Mapping($type, $properties);
     $mapping->disableSource($metadata->source);
     if (isset($metadata->boost)) {
         $mapping->setParam('_boost', array('name' => '_boost', 'null_value' => $metadata->boost));
     }
     if (isset($metadata->parent)) {
         $mapping->setParent($metadata->parent);
     }
     foreach ($rootProperties as $key => $value) {
         $mapping->setParam($key, $value);
     }
     $mapping->send();
     return $type;
 }
开发者ID:akleiber,项目名称:search,代码行数:22,代码来源:Client.php

示例9: analysis

 /**
  * Create Elastica Analysis.
  *
  * @param object $index Elastica Index
  * @param array $posttypes Array containing all post types
  * @param array $terms Array containing all terms
  * @return object $index Elastica Index
  *
  * @since 3.0.0
  */
 protected function analysis($index, $posttypes, $terms)
 {
     //Check integrity
     if (empty($index)) {
         return null;
     }
     //Check integrity
     if (empty($posttypes) && empty($terms)) {
         return null;
     }
     //Define properties
     $props = array('id' => array('type' => 'integer', 'include_in_all' => false), 'tags' => array('type' => 'string', 'index' => 'analyzed'), 'parent' => array('type' => 'integer', 'index' => 'analyzed'), 'title' => array('type' => 'string', 'index' => 'analyzed'), 'content' => array('type' => 'string', 'index' => 'analyzed'), 'excerpt' => array('type' => 'string', 'index' => 'analyzed'), 'author' => array('type' => 'integer', 'index' => 'analyzed'), 'date' => array('type' => 'date', 'format' => 'date_time_no_millis'), 'tags_suggest' => array('type' => 'completion', 'analyzer' => 'simple', 'search_analyzer' => 'simple', 'payloads' => false), '_boost' => array('type' => 'float', 'include_in_all' => false));
     /**
      * Update props analysis.
      *
      * @param array $props
      *
      * @since 3.3.0
      */
     do_action('tto_plugin_search_analysis', $props);
     //Set analysis
     if (isset($posttypes) && !empty($posttypes)) {
         foreach ($posttypes as $k) {
             if (empty($k)) {
                 continue;
             }
             $index->create(array('number_of_shards' => 4, 'number_of_replicas' => 1, 'analysis' => array('analyzer' => array('indexAnalyzer' => array('type' => 'custom', 'tokenizer' => 'standard', 'filter' => array('lowercase', 'asciifolding', 'filter_' . $k)), 'searchAnalyzer' => array('type' => 'custom', 'tokenizer' => 'standard', 'filter' => array('standard', 'lowercase', 'asciifolding', 'filter_' . $k))), 'filter' => array('filter_' . $k => array('type' => 'standard', 'language' => TTO_LOCAL, 'ignoreCase' => true)))), true);
             //Define new Type
             $type = $index->getType($k);
             //Define a new Elastica Mapper
             $mapping = new Mapping();
             $mapping->setType($type);
             //$mapping->setParam('analyzer', 'indexAnalyzer');
             //$mapping->setParam('search_analyzer', 'searchAnalyzer');
             //Define boost field
             /*$mapping->setParam('_boost', array(
                   'name' => '_boost',
                   'null_value' => 1.0
               ));*/
             //Set mapping
             $mapping->setProperties($props);
             //Send mapping to type
             $mapping->send();
         }
     }
     //Set analysis
     if (isset($terms) && !empty($terms)) {
         foreach ($terms as $t) {
             if (empty($t)) {
                 continue;
             }
             $index->create(array('number_of_shards' => 4, 'number_of_replicas' => 1, 'analysis' => array('analyzer' => array('indexAnalyzer' => array('type' => 'custom', 'tokenizer' => 'standard', 'filter' => array('lowercase', 'asciifolding', 'filter_' . $t)), 'searchAnalyzer' => array('type' => 'custom', 'tokenizer' => 'standard', 'filter' => array('standard', 'lowercase', 'asciifolding', 'filter_' . $t))), 'filter' => array('filter_' . $t => array('type' => 'standard', 'language' => TTO_LOCAL, 'ignoreCase' => true)))), true);
             //Define new Type
             $type = $index->getType($t);
             //Define a new Elastica Mapper
             $mapping = new Mapping();
             $mapping->setType($type);
             $mapping->setParam('index_analyzer', 'indexAnalyzer');
             $mapping->setParam('search_analyzer', 'searchAnalyzer');
             //Define boost field
             $mapping->setParam('_boost', array('name' => '_boost', 'null_value' => 1.0));
             //Set mapping
             $mapping->setProperties($props);
             // Send mapping to type
             $mapping->send();
         }
     }
     //Return index
     return $index;
 }
开发者ID:crewstyle,项目名称:TeaThemeOptions,代码行数:80,代码来源:Elastica.php

示例10: resetIndexType

 /**
  * Deletes and recreates a mapping type for the named index
  *
  * @param string $indexName
  * @param string $typeName
  * @throws \InvalidArgumentException if no index or type mapping exists for the given names
  * @throws ResponseException
  */
 public function resetIndexType($indexName, $typeName)
 {
     $typeConfig = $this->configManager->getTypeConfiguration($indexName, $typeName);
     $type = $this->indexManager->getIndex($indexName)->getType($typeName);
     try {
         $type->delete();
     } catch (ResponseException $e) {
         if (strpos($e->getMessage(), 'TypeMissingException') === false) {
             throw $e;
         }
     }
     $mapping = new Mapping();
     foreach ($this->mappingBuilder->buildTypeMapping($typeConfig) as $name => $field) {
         $mapping->setParam($name, $field);
     }
     $type->setMapping($mapping);
 }
开发者ID:benstinton,项目名称:FOSElasticaBundle,代码行数:25,代码来源:Resetter.php

示例11: getTypeMapping

 /**
  * @param Type $type
  * @param string $analyzer
  * @return Mapping
  */
 private function getTypeMapping(Type $type, $analyzer)
 {
     $mapping = new Mapping($type);
     $mapping->setParam('analyzer', $analyzer);
     $mapping->setProperties(['text' => ['type' => 'string', 'index' => 'analyzed', 'analyzer' => $analyzer], 'episode' => ['type' => 'object', 'properties' => ['id' => ['type' => 'integer'], 'number' => ['type' => 'integer'], 'name' => ['type' => 'string', 'index' => 'analyzed', 'analyzer' => $analyzer], 'slug' => ['type' => 'string', 'index' => 'not_analyzed']]], 'season' => ['type' => 'object', 'parameters' => ['id' => ['type' => 'integer'], 'number' => ['type' => 'integer']]], 'character' => ['type' => 'object', 'properties' => ['name' => ['type' => 'string', 'index' => 'not_analyzed'], 'slug' => ['type' => 'string', 'index' => 'not_analyzed']]], 'line' => ['type' => 'integer']]);
     return $mapping;
 }
开发者ID:stekycz,项目名称:dwarf-search,代码行数:12,代码来源:MappingCreator.php

示例12: resetIndexType

 /**
  * Deletes and recreates a mapping type for the named index.
  *
  * @param string $indexName
  * @param string $typeName
  *
  * @throws \InvalidArgumentException if no index or type mapping exists for the given names
  * @throws ResponseException
  */
 public function resetIndexType($indexName, $typeName)
 {
     $typeConfig = $this->configManager->getTypeConfiguration($indexName, $typeName);
     $index = $this->indexManager->getIndex($indexName);
     $type = $index->getType($typeName);
     $indexConfig = $this->configManager->getIndexConfiguration($indexName);
     $settings = $indexConfig->getSettings();
     $event = new TypeResetEvent($indexName, $typeName);
     $this->dispatcher->dispatch(TypeResetEvent::PRE_TYPE_RESET, $event);
     try {
         $type->delete();
     } catch (ResponseException $e) {
         if (strpos($e->getMessage(), 'TypeMissingException') === false) {
             throw $e;
         }
     }
     if (!empty($settings)) {
         $index->close();
         $index->setSettings($settings);
         $index->open();
     }
     $mapping = new Mapping();
     foreach ($this->mappingBuilder->buildTypeMapping($typeConfig) as $name => $field) {
         $mapping->setParam($name, $field);
     }
     $type->setMapping($mapping);
     $this->dispatcher->dispatch(TypeResetEvent::POST_TYPE_RESET, $event);
 }
开发者ID:eilgin,项目名称:FOSElasticaBundle,代码行数:37,代码来源:Resetter.php

示例13: resetIndexType

 /**
  * Deletes and recreates a mapping type for the named index.
  *
  * @param string $indexName
  * @param string $typeName
  *
  * @throws \InvalidArgumentException if no index or type mapping exists for the given names
  * @throws ResponseException
  */
 public function resetIndexType($indexName, $typeName)
 {
     $typeConfig = $this->configManager->getTypeConfiguration($indexName, $typeName);
     $this->resetIndex($indexName, true);
     $index = $this->indexManager->getIndex($indexName);
     $type = $index->getType($typeName);
     $event = new TypeResetEvent($indexName, $typeName);
     $this->dispatcher->dispatch(TypeResetEvent::PRE_TYPE_RESET, $event);
     if (!empty($settings)) {
         unset($settings['number_of_shards']);
         $index->close();
         $index->setSettings($settings);
         $index->open();
     }
     $mapping = new Mapping();
     foreach ($this->mappingBuilder->buildTypeMapping($typeConfig) as $name => $field) {
         $mapping->setParam($name, $field);
     }
     $type->setMapping($mapping);
     $this->dispatcher->dispatch(TypeResetEvent::POST_TYPE_RESET, $event);
 }
开发者ID:alekitto,项目名称:FOSElasticaBundle,代码行数:30,代码来源:Resetter.php

示例14: updateMapping

 /**
  * {@inheritdoc}
  */
 public function updateMapping(ClassMetadata $classMetadata)
 {
     try {
         $elasticaIndex = new Index($this->client, $classMetadata->getIndexForRead());
         $elasticaType = new Type($elasticaIndex, $classMetadata->type);
         $elasticaTypeMapping = new Mapping($elasticaType, $this->getMapping($classMetadata->fieldMappings));
         $elasticaTypeMapping->setParam('_id', array('path' => $classMetadata->getIdentifier()));
         if ($classMetadata->parent) {
             $elasticaTypeMapping->setParam('_parent', array('type' => $classMetadata->parent));
         }
         if ($classMetadata->dynamic) {
             $elasticaTypeMapping->setParam('dynamic', $classMetadata->dynamic);
         }
         $response = $elasticaType->setMapping($elasticaTypeMapping);
     } catch (\Exception $e) {
         return $e->getMessage();
     }
     return 200 == $response->getStatus() ? true : $response->getError();
 }
开发者ID:revinate,项目名称:search,代码行数:22,代码来源:Client.php

示例15: testGetMapping

 /**
  * @dataProvider providerTransport
  */
 public function testGetMapping(array $config, $transport)
 {
     $client = new Client($config);
     $index = $client->getIndex('test');
     $index->create(array(), true);
     $type = $index->getType('mappingTest');
     // Define mapping
     $mapping = new Mapping();
     $mapping->setParam('_boost', array('name' => '_boost', 'null_value' => 1.0));
     $mapping->setProperties(array('id' => array('type' => 'integer', 'include_in_all' => FALSE), 'user' => array('type' => 'object', 'properties' => array('name' => array('type' => 'string', 'include_in_all' => TRUE), 'fullName' => array('type' => 'string', 'include_in_all' => TRUE))), 'msg' => array('type' => 'string', 'include_in_all' => TRUE), 'tstamp' => array('type' => 'date', 'include_in_all' => FALSE), 'location' => array('type' => 'geo_point', 'include_in_all' => FALSE), '_boost' => array('type' => 'float', 'include_in_all' => FALSE)));
     $type->setMapping($mapping);
     $index->refresh();
     $times = array();
     for ($i = 0; $i < $this->_max; $i++) {
         $response = $type->request('_mapping', Request::GET);
         $times[] = $response->getQueryTime();
     }
     self::logResults('get mapping', $transport, $times);
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:22,代码来源:TransportTest.php


注:本文中的Elastica\Type\Mapping::setParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。