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


PHP Mapping::setType方法代码示例

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


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

示例1: postInstall

 public function postInstall(RecordInterface $record)
 {
     $client = new Client(array('host' => $this->registry['search.host'], 'port' => $this->registry['search.port']));
     $index = $client->getIndex('amun');
     $index->create();
     $type = $index->getType('page');
     $mapping = new Mapping();
     $mapping->setType($type);
     $mapping->setProperties(array('id' => array('type' => 'string', 'include_in_all' => false), 'userId' => array('type' => 'integer', 'include_in_all' => false), 'path' => array('type' => 'string', 'include_in_all' => true), 'title' => array('type' => 'string', 'include_in_all' => true), 'content' => array('type' => 'string', 'include_in_all' => true), 'date' => array('type' => 'date', 'include_in_all' => false)));
     $mapping->send();
 }
开发者ID:visapi,项目名称:amun,代码行数:11,代码来源:Setup.php

示例2: getType

 /**
  * @return Type
  */
 private function getType()
 {
     if (null === $this->type) {
         $this->type = $this->getIndex()->getType($this->typeName);
         $mapping = new Type\Mapping();
         $mapping->setType($this->type);
         $mapping->setTtl(['enabled' => true]);
         $mapping->setProperties([self::ID_FIELD => ['type' => 'string', 'include_in_all' => true], self::VALUE_FIELD => ['type' => 'string', 'include_in_all' => true]]);
         $mapping->send();
     }
     return $this->type;
 }
开发者ID:basster,项目名称:doctrine-elastica-cache,代码行数:15,代码来源:Cache.php

示例3: __construct

 /**
  * Creates a new Client of Elastica with the parameters $host and $port, And receive the index and type of stored data
  *
  * @param $user User Entity, $host string, $port string, $index string, $type string
  */
 public function __construct(User $user, $host, $port, $index, $type)
 {
     $this->user = $user;
     $this->client = new Client(array('host' => $host, 'port' => $port));
     $this->index = $this->client->getIndex($index);
     if (!$this->index->exists()) {
         $this->index->create();
         $this->index->refresh();
     }
     $this->type = $this->index->getType($type);
     $mapping = new Mapping();
     $mapping->setType($this->type);
     $mapping->setProperties(array('name' => array('type' => 'string'), 'email' => array('type' => 'string'), 'password' => array('type' => 'string')));
 }
开发者ID:ahmetakbn,项目名称:ElasticaClientUserBundle,代码行数:19,代码来源:ElasticaUserService.php

示例4: create

 /**
  * Create the mapping for the type.
  *
  * @param \Cake\Datasource\ConnectionInterface $db The Elasticsearch connection
  * @return void
  */
 public function create(ConnectionInterface $db)
 {
     if (empty($this->schema)) {
         return;
     }
     $index = $db->getIndex();
     if (!$index->exists()) {
         $index->create();
     }
     $type = $index->getType($this->table);
     $mapping = new ElasticaMapping();
     $mapping->setType($type);
     $mapping->setProperties($this->schema);
     $mapping->send();
     $this->created[] = $db->configName();
 }
开发者ID:edukondaluetg,项目名称:elastic-search,代码行数:22,代码来源:TestFixture.php

示例5: main

 /**
  * Creates the elastic search mapping for the provided table, or just prints it out
  * to the screen if the `dry-run` option is provided.
  *
  * @param string $table The table name to inspect and create a mapping for
  * @return bool
  */
 public function main($table)
 {
     $table = TableRegistry::get($table);
     $schema = $table->schema();
     $mapping = ['@timestamp' => ['type' => 'date', 'format' => 'basic_t_time_no_millis||dateOptionalTime||basic_date_time||ordinal_date_time_no_millis||yyyy-MM-dd HH:mm:ss'], 'transaction' => ['type' => 'string', 'index' => 'not_analyzed'], 'type' => ['type' => 'string', 'index' => 'not_analyzed'], 'primary_key' => ['type' => 'string', 'index' => 'not_analyzed'], 'source' => ['type' => 'string', 'index' => 'not_analyzed'], 'parent_source' => ['type' => 'string', 'index' => 'not_analyzed'], 'original' => ['properties' => []], 'changed' => ['properties' => []], 'meta' => ['properties' => ['ip' => ['type' => 'string', 'index' => 'not_analyzed'], 'url' => ['type' => 'string', 'index' => 'not_analyzed'], 'user' => ['type' => 'string', 'index' => 'not_analyzed'], 'app_name' => ['type' => 'string', 'index' => 'not_analyzed']]]];
     $properties = [];
     foreach ($schema->columns() as $column) {
         $properties[$column] = $this->mapType($schema, $column);
     }
     if ($table->hasBehavior('AuditLog')) {
         $whitelist = (array) $table->behaviors()->AuditLog->config('whitelist');
         $blacklist = (array) $table->behaviors()->AuditLog->config('blacklist');
         $properties = empty($whitelist) ? $properties : array_intersect_key($properties, array_flip($whitelist));
         $properties = array_diff_key($properties, array_flip($blacklist));
     }
     $mapping['original']['properties'] = $mapping['changed']['properties'] = $properties;
     $client = ConnectionManager::get('auditlog_elastic');
     $index = $client->getIndex(sprintf($client->getConfig('index'), '-' . gmdate('Y.m.d')));
     $type = $index->getType($table->table());
     $elasticMapping = new ElasticaMapping();
     $elasticMapping->setType($type);
     $elasticMapping->setProperties($mapping);
     if ($this->params['dry-run']) {
         $this->out(json_encode($elasticMapping->toArray(), JSON_PRETTY_PRINT));
         return true;
     }
     if ($this->params['use-templates']) {
         $template = ['template' => sprintf($client->getConfig('index'), '*'), 'mappings' => $elasticMapping->toArray()];
         $response = $client->request('_template/template_' . $type->getName(), Request::PUT, $template);
         $this->out('<success>Successfully created the mapping template</success>');
         return $response->isOk();
     }
     if (!$index->exists()) {
         $index->create();
     }
     $elasticMapping->send();
     $this->out('<success>Successfully created the mapping</success>');
     return true;
 }
开发者ID:lorenzo,项目名称:audit-stash,代码行数:46,代码来源:ElasticMappingShell.php

示例6: getMapping

 /**
  * Return default search fields mapping for node translations
  *
  * @param Index  $index
  * @param string $lang
  *
  * @return Mapping
  */
 protected function getMapping(Index $index, $lang = 'en')
 {
     $mapping = new Mapping();
     $mapping->setType($index->getType($this->indexType . '_' . $lang));
     $mapping->setParam('analyzer', 'index_analyzer_' . $lang);
     $mapping->setParam('_boost', array('name' => '_boost', 'null_value' => 1.0));
     $mapping->setProperties($this->properties);
     return $mapping;
 }
开发者ID:henrypenny,项目名称:KunstmaanBundlesCMS,代码行数:17,代码来源:NodePagesConfiguration.php

示例7: createMapping

 protected function createMapping()
 {
     dump(__METHOD__);
     $type = $this->getClient()->getIndex($this->getIndexName())->getType($this->getTypeName());
     $mapping = new Mapping();
     $mapping->setType($type);
     $mappingProperties = (new MappingFactory())->make();
     $mapping->setProperties($mappingProperties);
     $response = $mapping->send();
     //        dump($response);
     $this->assertNotTrue($response->hasError());
     return $mappingProperties;
 }
开发者ID:jiangyu7408,项目名称:notification,代码行数:13,代码来源:MappingTest.php

示例8: store

 /**
  * {@inheritdoc}
  */
 public function store(array $data, array $keys, $namespace)
 {
     $type = $this->index->getType($namespace);
     // Build mapping
     $mapping = new Mapping();
     $mapping->setType($type);
     $mapping->setProperties(array('hash' => array('type' => 'string', 'include_in_all' => true), 'keys' => array('type' => 'string', 'include_in_all' => true)));
     $mapping->send();
     // Build document
     $document = new Document('', array_merge($data, array('hash' => $this->getHash($data, $keys), 'keys' => $keys)));
     $type->addDocument($document);
     $this->index->refresh();
 }
开发者ID:Tessi-Tms,项目名称:TmsDataLimitNamespaceBundle,代码行数:16,代码来源:ElasticSearchDataProvider.php

示例9: setMapping

 /**
  * @param array $mappingArray
  * @param Elastica\Type $type
  */
 protected function setMapping(array $mappingArray, Elastica\Type $type)
 {
     try {
         $mapping = new Elastica\Type\Mapping();
         $mapping->setType($type);
         $mapping->setProperties($mappingArray);
         $mapping->send();
     } catch (\Exception $e) {
         $this->outputLine('Could not add mapping for type ' . $type->getName() . '. Message was ' . $e->getMessage());
     }
 }
开发者ID:randomresult,项目名称:WMDB.Forger,代码行数:15,代码来源:SetupCommandController.php

示例10: 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

示例11: setMapping

 /**
  * @param Index $elasticaIndex
  */
 protected function setMapping(Index $elasticaIndex)
 {
     foreach ($this->configuration->getTypes() as $typeName) {
         $mapping = new Mapping();
         $type = $elasticaIndex->getType($typeName);
         $mapping->setType($type);
         // Set properties
         if ($properties = $this->configuration->getMappingProperties($type)) {
             $mapping->setProperties($properties);
         }
         // Set params if any
         if ($mappingParams = $this->configuration->getMappingParams($type)) {
             foreach ($mappingParams as $mappingParam => $mappingParamValue) {
                 $mapping->setParam($mappingParam, $mappingParamValue);
             }
         }
         if ($mappingParams || $properties) {
             $mapping->send();
         }
     }
 }
开发者ID:darklow,项目名称:ff-elastica-manager,代码行数:24,代码来源:IndexManager.php

示例12: createMappings

 /**
  * Define all known mappings
  */
 protected function createMappings(\Elastica\Index $index)
 {
     foreach ($this->getIndexedClasses() as $class) {
         /** @var $sng Searchable */
         $sng = singleton($class);
         $type = $sng->getElasticaType();
         if (isset($this->mappings[$type])) {
             // captured later
             continue;
         }
         $mapping = $sng->getElasticaMapping();
         $mapping->setType($index->getType($type));
         $mapping->send();
     }
     if ($this->mappings) {
         foreach ($this->mappings as $type => $fields) {
             $mapping = new Mapping();
             $mapping->setProperties($fields);
             $mapping->setParam('date_detection', false);
             $mapping->setType($index->getType($type));
             $mapping->send();
         }
     }
 }
开发者ID:ajshort,项目名称:silverstripe-elastica,代码行数:27,代码来源:ElasticaService.php

示例13: function

<?php

/**
 * Created by PhpStorm.
 * User: Jiang Yu
 * Date: 2016/04/22
 * Time: 16:11.
 */
use Elastica\Type\Mapping;
use ESGateway\DataModel\FieldMapping\MappingFactory;
require __DIR__ . '/../../bootstrap.php';
$createMappingHandler = function (\Elastica\Type $type) {
    $mapping = new Mapping();
    $mapping->setType($type);
    $mappingProperties = (new MappingFactory())->make();
    $mapping->setProperties($mappingProperties);
    $response = $mapping->send();
    dump('create default mapping');
    dump($response);
};
$options = getopt('', ['gv:', 'index:', 'createIndex:']);
$client = new \Elastica\Client(['host' => ELASTIC_SEARCH_HOST, 'port' => ELASTIC_SEARCH_PORT]);
if (isset($options['createIndex'])) {
    $indexName = trim($options['createIndex']);
    assert(is_string($indexName) && strlen($indexName) > 0 && strpos($indexName, 'farm_v') === 0, 'bad index name');
    $index = $client->getIndex($indexName);
    $exists = $index->exists();
    if (!$exists) {
        $response = $index->create();
        dump('create index');
        dump($response);
开发者ID:jiangyu7408,项目名称:notification,代码行数:31,代码来源:indexHelper.php

示例14: createDefaultSearchFieldsMapping

 /**
  * Return default search fields mapping for node translations
  *
  * @param Index  $index
  * @param string $lang
  *
  * @return Mapping
  */
 protected function createDefaultSearchFieldsMapping(Index $index, $lang = 'en')
 {
     $mapping = new Mapping();
     $mapping->setType($index->getType($this->indexType));
     $mapping->setProperties($this->properties);
     return $mapping;
 }
开发者ID:bakie,项目名称:KunstmaanBundlesCMS,代码行数:15,代码来源:NodePagesConfiguration.php

示例15: createMapping

 /**
  * Creates a new mapping object
  *
  * @param Elastica\Type $type  the type where you want to create your mapping
  * @param Array         $array the mapping which you want to create
  *
  * @return void
  */
 function createMapping($type, $array)
 {
     // Define mapping
     $mapping = new Mapping();
     $mapping->setType($type);
     // Set mapping
     $mapping->setProperties($array);
     // Send mapping to type
     $mapping->send();
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:18,代码来源:CSearch.class.php


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