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


PHP Search::count方法代码示例

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


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

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

示例2: searchAction

 public function searchAction()
 {
     //WIP, todo: export to repository and use it in Search Playlists
     $elasticaClient = new Client();
     $playListIndex = $elasticaClient->getIndex('playlist');
     $trackType = $playListIndex->getType('track');
     $search = new Search($elasticaClient);
     $search->addIndex($playListIndex)->addType($trackType);
     $query = new Query();
     $query->setSize(5)->setSort(['name' => 'asc'])->setFields(['name', 'ids', 'id', 'composer'])->setExplain(true)->setVersion(true)->setHighlight(['fields' => 'composer']);
     $query->setQuery(new MatchAll());
     //        $query->addAggregation(new \Elastica\Aggregation\Range('name'));
     //        $term = new \Elastica\Suggest\Term('name', 'field');
     //        $term->setText('aaaaa');
     //        $query->setSuggest(new \Elastica\Suggest($term));
     //        $query->setFacets([new \Elastica\Facet\Range('name')]);
     $search->setQuery($query);
     $resultSet = $search->search();
     $numberOfEntries = $search->count();
     $results = $resultSet->getResults();
     $totalResults = $resultSet->getTotalHits();
     return $this->render('PlayWithElasticSearchBundle:Elastica:search.html.twig', ['query' => $query, 'numberOfEntries' => $numberOfEntries, 'resultSet' => $resultSet, 'results' => $results, 'totalResults' => $totalResults]);
 }
开发者ID:slaparra,项目名称:Training-Elastic-Search-Symfony,代码行数:23,代码来源:ElasticaController.php

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

示例4: getItemCount

 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getItemCount()
 {
     return $this->search->count();
 }
开发者ID:kgilden,项目名称:pager,代码行数:9,代码来源:ElasticaAdapter.php

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

示例6: getCount

 function getCount()
 {
     $search = new Search($this->client);
     $count = $search->count($this->query->toArray());
     return $count->count();
 }
开发者ID:splitice,项目名称:radical-pagination-els,代码行数:6,代码来源:ELSAdapter.php

示例7: testCountRequest

 public function testCountRequest()
 {
     $client = $this->_getClient();
     $search = new Search($client);
     $index = $client->getIndex('zero');
     $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
     $docs = array();
     $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
     $type = $index->getType('zeroType');
     $type->addDocuments($docs);
     $index->refresh();
     $search->addIndex($index)->addType($type);
     $count = $search->count('farrelley');
     $this->assertEquals(11, $count);
 }
开发者ID:kskod,项目名称:Elastica,代码行数:25,代码来源:SearchTest.php


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