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


PHP Search::setOption方法代码示例

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


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

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

示例2: testQueryCacheOption

 /**
  * @group functional
  */
 public function testQueryCacheOption()
 {
     $client = $this->_getClient();
     $index = $client->getIndex('zero');
     $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
     $type = $index->getType('zeroType');
     $type->addDocuments(array(new Document(1, array('id' => 1, 'username' => 'farrelley')), new Document(2, array('id' => 2, 'username' => 'bunny'))));
     $index->refresh();
     $aggregation = new Aggregation\Terms('username');
     $aggregation->setField('username');
     $query = new Query();
     $query->addAggregation($aggregation);
     $search = new Search($client);
     $search->addIndex($index);
     $search->setQuery($query);
     $search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_COUNT);
     $search->setOption(Search::OPTION_QUERY_CACHE, true);
     // before search query cache should be empty
     $statsData = $index->getStats()->getData();
     $queryCache = $statsData['_all']['primaries']['query_cache'];
     $this->assertEquals(0, $queryCache['memory_size_in_bytes']);
     $this->assertEquals(0, $queryCache['evictions']);
     $this->assertEquals(0, $queryCache['hit_count']);
     $this->assertEquals(0, $queryCache['miss_count']);
     // first search should result in cache miss and save data to cache
     $search->search();
     $index->getStats()->refresh();
     $statsData = $index->getStats()->getData();
     $queryCache = $statsData['_all']['primaries']['query_cache'];
     $this->assertNotEquals(0, $queryCache['memory_size_in_bytes']);
     $this->assertEquals(0, $queryCache['evictions']);
     $this->assertEquals(0, $queryCache['hit_count']);
     $this->assertEquals(1, $queryCache['miss_count']);
     // next search should result in cache hit
     $search->search();
     $index->getStats()->refresh();
     $statsData = $index->getStats()->getData();
     $queryCache = $statsData['_all']['primaries']['query_cache'];
     $this->assertNotEquals(0, $queryCache['memory_size_in_bytes']);
     $this->assertEquals(0, $queryCache['evictions']);
     $this->assertEquals(1, $queryCache['hit_count']);
     $this->assertEquals(1, $queryCache['miss_count']);
 }
开发者ID:nadeem-khan,项目名称:Elastica,代码行数:46,代码来源:SearchTest.php

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


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