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


PHP Search::addType方法代码示例

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


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

示例1: getSearchResult

 /**
  * @return \Elastica\ResultSet
  */
 public function getSearchResult()
 {
     $index = $this->search->getIndex($this->getIndexName() . '_' . $this->language);
     $search = new Search($this->search->getClient());
     $search->addIndex($index);
     $search->addType($index->getType($this->indexType));
     $result = $search->search($this->query);
     return $result;
 }
开发者ID:bakie,项目名称:KunstmaanBundlesCMS,代码行数:12,代码来源:AbstractElasticaSearcher.php

示例2: getElasticaCount

 /**
  * Get Query Count
  *
  * @param string $index        	
  * @param string $type        	
  *
  * @return number
  */
 public function getElasticaCount($index = false, $type = false)
 {
     $elastica_query = new Query();
     $elastica_client = $this->getElasticaClient();
     // If you want to restrict your search to a particular index then get
     // that
     $elastica_index = $index ? $elastica_client->getIndex($index) : false;
     // If you want to restrict your search to a particular type then get
     // that
     $elastica_type = $elastica_index && $type ? $elastica_index->getType($type) : false;
     $elastica_search = new Search($elastica_client);
     if ($elastica_index) {
         $elastica_search->addIndex($elastica_index);
     }
     if ($elastica_type) {
         $elastica_search->addType($elastica_type);
     }
     return $elastica_search->count($elastica_query);
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:27,代码来源:ElasticaAwareTrait.php

示例3: readData

 public function readData($source_definition, $rest_parameters = [])
 {
     Pager::setDefaultLimit(500);
     list($limit, $offset) = Pager::calculateLimitAndOffset();
     $client = new Client(['host' => $source_definition['host'], 'port' => $source_definition['port'], 'username' => $source_definition['username'], 'password' => $source_definition['password']]);
     $index = $client->getIndex($source_definition['es_index']);
     $type = $index->getType($source_definition['es_type']);
     $search = new Search($client);
     $search->addIndex($index);
     $search->addType($type);
     $query_param = \Input::get('query');
     if (empty($query_param)) {
         $query = new MatchAll();
         $search->setQuery($query);
     } else {
         $query = new SimpleQueryString($query_param);
         $search->setQuery($query);
     }
     $search->getQuery()->setFrom($offset);
     $search->getQuery()->setSize($limit);
     $resultSet = $search->search();
     $data = new Data();
     $data_results = [];
     foreach ($resultSet->getResults() as $result) {
         $data_result = $result->getData();
         unset($data_result['__tdt_etl_timestamp__']);
         $data_results[] = $data_result;
     }
     $data->data = $data_results;
     if ($resultSet->getTotalHits() > 0) {
         $paging = Pager::calculatePagingHeaders($limit, $offset, $resultSet->getTotalHits());
         $data->paging = $paging;
     }
     $data->preferred_formats = $this->getPreferredFormats();
     return $data;
 }
开发者ID:tdt,项目名称:core,代码行数:36,代码来源:ELASTICSEARCHController.php

示例4: testCount

 /**
  * @group functional
  */
 public function testCount()
 {
     $index = $this->_createIndex();
     $search = new Search($index->getClient());
     $type = $index->getType('test');
     $doc = new Document(1, array('id' => 1, 'username' => 'ruflin'));
     $type->addDocument($doc);
     $index->refresh();
     $search->addIndex($index);
     $search->addType($type);
     $result1 = $search->count(new \Elastica\Query\MatchAll());
     $this->assertEquals(1, $result1);
     $result2 = $search->count(new \Elastica\Query\MatchAll(), true);
     $this->assertInstanceOf('\\Elastica\\ResultSet', $result2);
     $this->assertEquals(1, $result2->getTotalHits());
 }
开发者ID:levijackson,项目名称:Elastica,代码行数:19,代码来源:SearchTest.php

示例5: createSearch

 /**
  * Create search object
  *
  * @param  string|array|\Elastica\Query $query   Array with all query data inside or a Elastica\Query object
  * @param  int|array                   $options OPTIONAL Limit or associative array of options (option=>value)
  * @return \Elastica\Search
  */
 public function createSearch($query = '', $options = null)
 {
     $search = new Search($this->getIndex()->getClient());
     $search->addIndex($this->getIndex());
     $search->addType($this);
     $search->setOptionsAndQuery($options, $query);
     return $search;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:15,代码来源:Type.php

示例6: buildQuery

 protected function buildQuery(array $classes)
 {
     $searchQuery = new Search($this->client);
     $searchQuery->setOption(Search::OPTION_VERSION, true);
     foreach ($classes as $class) {
         if ($class->index) {
             $indexObject = $this->getIndex($class->index);
             $searchQuery->addIndex($indexObject);
             if ($class->type) {
                 $searchQuery->addType($indexObject->getType($class->type));
             }
         }
     }
     return $searchQuery;
 }
开发者ID:akleiber,项目名称:search,代码行数:15,代码来源:Client.php

示例7: buildCount

 /**
  * Build a Search that will count all pages that link to $titles.
  * @param string $titles title in prefixedDBKey form
  * @return Search that counts all pages that link to $titles
  */
 private function buildCount($titles)
 {
     $filter = new Terms('outgoing_link', $titles);
     $filter->setCached(false);
     // We're not going to be redoing this any time soon.
     $type = $this->connection->getPageType(wfWikiId());
     $search = new Search($type->getIndex()->getClient());
     $search->addIndex($type->getIndex());
     $search->addType($type);
     $search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_COUNT);
     $matchAll = new MatchAll();
     $search->setQuery(new Filtered($matchAll, $filter));
     $search->getQuery()->addParam('stats', 'link_count');
     return $search;
 }
开发者ID:zoglun,项目名称:mediawiki-extensions-CirrusSearch,代码行数:20,代码来源:RedirectsAndIncomingLinks.php

示例8: count

 /**
  * Invoke Elasticsearch count.
  *
  * @param Query  $query
  * @param string $index
  * @param string $type
  * @param array  $options
  *
  * @return \Elastica\ResultSet
  */
 public function count($query, $type, $index = 'activehire', $options = [])
 {
     $search = new Search($this->client);
     $search->addType($type);
     $search->addIndex($index);
     $search->setOptions($options);
     $result = $search->count($query);
     return $result;
 }
开发者ID:phpfour,项目名称:ah,代码行数:19,代码来源:Elastica.php

示例9: getScanAndScroll

 /**
  * @return ScanAndScroll
  */
 protected function getScanAndScroll()
 {
     $search = new Search($this->client);
     $search->addIndex($this->elasticaIndex);
     // type не обязателен, бэкапить можно весь индекс со всеми типами
     if ($this->typeName) {
         $search->addType($this->elasticaType);
     }
     $scanAndScroll = new ScanAndScroll($search);
     $scanAndScroll->sizePerShard = $this->sizePerShard;
     $scanAndScroll->expiryTime = $this->expiryTime;
     return $scanAndScroll;
 }
开发者ID:mzf,项目名称:phalcon-php-elasticsearch-backup,代码行数:16,代码来源:elasticsearch-dumper.php

示例10: testSearchRequest

 public function testSearchRequest()
 {
     $client = $this->_getClient();
     $search1 = new Search($client);
     $index1 = $this->_createIndex('test1');
     $index2 = $this->_createIndex('test2');
     $type1 = $index1->getType('hello1');
     $result = $search1->search(array());
     $this->assertFalse($result->getResponse()->hasError());
     $search1->addIndex($index1);
     $result = $search1->search(array());
     $this->assertFalse($result->getResponse()->hasError());
     $search1->addIndex($index2);
     $result = $search1->search(array());
     $this->assertFalse($result->getResponse()->hasError());
     $search1->addType($type1);
     $result = $search1->search(array());
     $this->assertFalse($result->getResponse()->hasError());
 }
开发者ID:kskod,项目名称:Elastica,代码行数:19,代码来源:SearchTest.php


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