• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Solarium_Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Solarium_Client的典型用法代码示例。如果您正苦于以下问题:PHP Solarium_Client类的具体用法?PHP Solarium_Client怎么用?PHP Solarium_Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getIds

 protected function getIds()
 {
     $client = new Solarium_Client($this->CONFIG);
     $select = $client->createSelect();
     $select->setRows(20000);
     $select->createFilterQuery('users')->setQuery('activeusers:[0 TO *]');
     $select->createFilterQuery('pages')->setQuery('wikipages:[500 TO *]');
     $select->createFilterQuery('words')->setQuery('words:[10 TO *]');
     $select->createFilterQuery('ns')->setQuery('ns:0');
     $select->createFilterQuery('wam')->setQuery('-(wam:0)');
     $select->createFilterQuery('dis')->setQuery('-(title_en:disambiguation)');
     $select->createFilterQuery('answer_host')->setQuery('-(host:*answers.wikia.com)');
     $select->createFilterQuery('answer')->setQuery('-(hub:Wikianswers)');
     //speedydeletion: 547090, scratchpad: 95, lyrics:43339, colors:32379
     $select->createFilterQuery('banned')->setQuery('-(wid:547090) AND -(wid:95) AND -(wid:43339) AND -(wid:32379)');
     // faceting would be less expensive
     $select->addParam('group', 'true');
     $select->addParam('group.field', 'wid');
     $select->addParam('group.ngroups', 'true');
     $result = $client->select($select);
     $ids = [];
     if (isset($result->getData()['grouped']['wid']['groups'])) {
         foreach ($result->getData()['grouped']['wid']['groups'] as $group) {
             $ids[] = $group['groupValue'];
         }
     }
     return $ids;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:28,代码来源:WIDlist.php


示例2: indexAction

 /** Display of publications with filtration
  */
 public function indexAction()
 {
     $limit = 20;
     $page = $this->_getParam('page');
     if (!isset($page)) {
         $start = 0;
     } else {
         unset($params['page']);
         $start = ($page - 1) * 20;
     }
     $config = array('adapteroptions' => array('host' => '127.0.0.1', 'port' => 8983, 'path' => '/solr/', 'core' => 'beopublications'));
     $select = array('query' => '*:*', 'start' => $start, 'rows' => $limit, 'fields' => array('*'), 'sort' => array('title' => 'asc'), 'filterquery' => array());
     $client = new Solarium_Client($config);
     // get a select query instance based on the config
     $query = $client->createSelect($select);
     $resultset = $client->select($query);
     $data = NULL;
     foreach ($resultset as $doc) {
         foreach ($doc as $key => $value) {
             $fields[$key] = $value;
         }
         $data[] = $fields;
     }
     $paginator = Zend_Paginator::factory($resultset->getNumFound());
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($limit)->setPageRange(20);
     $this->view->paginator = $paginator;
     $this->view->results = $data;
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:30,代码来源:PublicationsController.php


示例3: delete

 /** Delete record by ID
  * 
  * @param $id
  */
 public function delete($id)
 {
     $solr = new Solarium_Client(array('adapteroptions' => array('host' => '127.0.0.1', 'port' => 8983, 'path' => '/solr/', 'core' => 'beowulf')));
     $update = $solr->createUpdate();
     $update->addDeleteById('findIdentifier-' . $id);
     $update->addCommit();
     $result = $solr->update($update);
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:12,代码来源:Updater.php


示例4: handle

 function handle($args)
 {
     /*
      * Make sure we have a search term.
      */
     if (!isset($args['term']) || empty($args['term'])) {
         json_error('Search term not provided.');
         die;
     }
     /*
      * Clean up the search term.
      */
     $term = filter_var($args['term'], FILTER_SANITIZE_STRING);
     /*
      * Append an asterix to the search term, so that Solr can suggest autocomplete terms.
      */
     $term .= '*';
     /*
      * Intialize Solarium.
      */
     $client = new Solarium_Client($GLOBALS['solr_config']);
     /*
      * Set up our query.
      */
     $query = $client->createSuggester();
     $query->setHandler('suggest');
     $query->setQuery($term);
     $query->setOnlyMorePopular(TRUE);
     $query->setCount(5);
     $query->setCollate(TRUE);
     /*
      * Execute the query.
      */
     $search_results = $client->suggester($query);
     /*
      * If there are no results.
      */
     if (count($search_results) == 0) {
         $response->terms = FALSE;
     } else {
         $response->terms = array();
         foreach ($search_results as $term => $term_result) {
             $i = 0;
             foreach ($term_result as $suggestion) {
                 $response->terms[] = array('id' => $i, 'term' => $suggestion);
                 $i++;
             }
         }
     }
     $this->render($response, 'OK');
 }
开发者ID:FreeLawFounders,项目名称:statedecoded,代码行数:51,代码来源:class.APISuggestController.inc.php


示例5: __construct

 /** The constructor
  *
  */
 public function __construct()
 {
     $this->_cache = Zend_Registry::get('cache');
     $this->_config = Zend_Registry::get('config');
     $this->_solrConfig = array('adapteroptions' => $this->_config->solr->toArray());
     $this->_solr = new Solarium_Client($this->_solrConfig);
     $this->_solr->setAdapter('Solarium_Client_Adapter_ZendHttp');
     $loadbalancer = $this->_solr->getPlugin('loadbalancer');
     $master = $this->_config->solr->master->toArray();
     $slave = $this->_config->solr->slave->toArray();
     $loadbalancer->addServer('master', $master, 100);
     $loadbalancer->addServer('slave', $slave, 200);
     $loadbalancer->setFailoverEnabled(true);
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:17,代码来源:MoreLikeThis.php


示例6: getSMRSNearbyFinds

 /** Find objects recorded with proximity to SMRs within a certain distance
  * of a lat lon pair, this is set up to work in kilometres from point. You
  * can adapt this for miles. This perhaps can be swapped out for a SOLR
  * based search in future.
  * @access public
  * @param double $lat
  * @param double $long
  * @param integer $distance
  * @return array
  */
 public function getSMRSNearbyFinds($lat, $lon, $distance)
 {
     $config = $this->_config->solr->asgard->toArray();
     $config['core'] = 'objects';
     $solr = new Solarium_Client(array('adapteroptions' => $config));
     $select = array('query' => '*:*', 'fields' => array('*'), 'filterquery' => array());
     $query = $solr->createSelect($select);
     $helper = $query->getHelper();
     $query->createFilterQuery('geofilt')->setQuery($helper->geofilt($lat, $lon, 'coordinates', $distance));
     $resultset = $solr->select($query);
     $data = array();
     foreach ($resultset as $document) {
         $data[] = array('id' => $document['id'], 'old_findID' => $document['old_findID'], 'county' => $document['county'], 'broadperiod' => $document['broadperiod']);
     }
     return $data;
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:26,代码来源:ScheduledMonuments.php


示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $parts = parse_url($input->getArgument('url'));
     $config = array('adapteroptions' => array('host' => $parts['host'], 'port' => isset($parts['port']) ? $parts['port'] : 80, 'path' => $parts['path']));
     $client = new \Solarium_Client($config);
     $ping = $client->createPing();
     $q_start = microtime(TRUE);
     $response = $client->execute($ping);
     $client_query_time = round((microtime(TRUE) - $q_start) * 1000, 1) . 'ms';
     $body = $response->getResponse()->getBody();
     if (!empty($body)) {
         $data = json_decode($body);
         $status = isset($data->status) ? $data->status : 'Unknown';
         $server_query_time = isset($data->responseHeader->QTime) ? $data->responseHeader->QTime . 'ms' : 'Unknown';
         $output->writeln("Ping status {$status} completed in (client/server) {$client_query_time}/{$server_query_time}");
     }
 }
开发者ID:danquah,项目名称:solr-tester,代码行数:19,代码来源:PingCommand.php


示例8: testCreateQueryPostPlugin

 public function testCreateQueryPostPlugin()
 {
     $type = Solarium_Client::QUERYTYPE_SELECT;
     $options = array('optionA' => 1, 'optionB' => 2);
     $query = $this->_client->createQuery($type, $options);
     $observer = $this->getMock('Solarium_Plugin_Abstract', array(), array($this->_client, array()));
     $observer->expects($this->once())->method('postCreateQuery')->with($this->equalTo($type), $this->equalTo($options), $this->equalTo($query));
     $this->_client->registerPlugin('testplugin', $observer);
     $this->_client->createQuery($type, $options);
 }
开发者ID:realestateconz,项目名称:solarium,代码行数:10,代码来源:ClientTest.php


示例9: getSolr

 /** Get the solr object for querying cores
  * @access public
  * @return \Solarium_Client
  */
 public function getSolr()
 {
     $this->_solr = new Solarium_Client($this->getSolrConfig());
     $this->_solr->setAdapter('Solarium_Client_Adapter_ZendHttp');
     $this->_solr->getAdapter()->getZendHttp();
     $loadbalancer = $this->_solr->getPlugin('loadbalancer');
     $master = $this->getConfig()->solr->master->toArray();
     $asgard = $this->getConfig()->solr->asgard->toArray();
     $valhalla = $this->getConfig()->solr->valhalla->toArray();
     $loadbalancer->addServer('objects', $master, 100);
     $loadbalancer->addServer('asgard', $asgard, 200);
     $loadbalancer->addServer('valhalla', $valhalla, 150);
     $loadbalancer->setFailoverEnabled(true);
     $this->_solr->getAdapter()->getZendHttp();
     $this->_loadbalancer = $loadbalancer;
     return $this->_solr;
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:21,代码来源:Handler.php


示例10: testFailoverMaxRetries

 public function testFailoverMaxRetries()
 {
     $this->_plugin = new TestLoadbalancer();
     // special loadbalancer that returns servers in fixed order
     $this->_client = new Solarium_Client();
     $adapter = new TestAdapterForFailover();
     $adapter->setFailCount(10);
     $this->_client->setAdapter($adapter);
     // set special mock that fails for all servers
     $this->_plugin->init($this->_client, array());
     $request = new Solarium_Client_Request();
     $servers = array('s1' => array('options' => $this->_serverOptions, 'weight' => 1), 's2' => array('options' => $this->_serverOptions, 'weight' => 1));
     $this->_plugin->setServers($servers);
     $this->_plugin->setFailoverEnabled(true);
     $query = new Solarium_Query_Select();
     $this->_plugin->preCreateRequest($query);
     $this->setExpectedException('Solarium_Exception', 'Maximum number of loadbalancer retries reached');
     $this->_plugin->preExecuteRequest($request);
 }
开发者ID:Bine0511,项目名称:RDF-Demo,代码行数:19,代码来源:LoadbalancerTest.php


示例11: htmlHeader

<?php

require 'init.php';
htmlHeader();
// This example shows how to manually execute the query flow.
// By doing this manually you can customize data in between any step (although a plugin might be better for this)
// And you can use only a part of the flow. You could for instance use the query object and request builder,
// but execute the request in your own code.
// create a client instance
$client = new Solarium_Client($config);
// create a select query instance
$query = $client->createSelect();
// manually create a request for the query
$request = $client->createRequest($query);
// you can now use the request object for getting an uri (ie. to use in you own code)
// or you could modify the request object
echo 'Request URI: ' . $request->getUri() . '<br/>';
// you can still execute the request using the client and get a 'raw' response object
$response = $client->executeRequest($request);
// and finally you can convert the response into a result
$result = $client->createResult($query, $response);
// display the total number of documents found by solr
echo 'NumFound: ' . $result->getNumFound();
// show documents using the resultset iterator
foreach ($result as $document) {
    echo '<hr/><table>';
    // the documents are also iterable, to get all fields
    foreach ($document as $field => $value) {
        // this converts multivalue fields to a comma-separated string
        if (is_array($value)) {
            $value = implode(', ', $value);
开发者ID:swapnilphalak,项目名称:crawl-anywhere,代码行数:31,代码来源:5.1-partial-usage.php


示例12: array

//        'localhost' => array(
//            'host' => '188.40.100.77',
//            'port' => 8080,
//            'path' => '/solr',
//            'timeout'=> 50,
//            'core' => 'collectionv2',
//        )
//    )
//);
$server = "178.63.79.68";
//$server = "188.40.100.77";
$config = array('adapteroptions' => array('host' => $server, 'port' => 8080, 'path' => '/solr/', 'core' => 'collectionv2'));
$limit = 10;
$offset = 0;
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
$keyword = isset($argv[1]) ? $argv[1] : "*";
//$keyword = str_replace(" ", "*", $keyword);
//$matchingText = explode(" ",trim($keyword));
//for($i=0; $i<count($matchingText);$i++){
//    if($i == 0){
//        $keyword = $matchingText[$i]."+".$matchingText[$i]."*";
//    }else{
//        $keyword = $keyword."+".$matchingText[$i]."+".$matchingText[$i]."*";
//    }
//}
// apply settings using the API
//$query->setQuery($q);
//$query->setStart($offset)->setRows($limit);
开发者ID:parvbhullar,项目名称:test,代码行数:31,代码来源:solr.php


示例13: htmlHeader

<?php

require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get an update query instance
$update = $client->createUpdate();
// add the delete query and a commit command to the update query
$update->addDeleteQuery('name:testdoc*');
$update->addCommit();
// this executes the query and returns the result
$result = $client->update($update);
echo '<b>Update query executed<b><br/>';
echo 'Query status: ' . $result->getStatus() . '<br/>';
echo 'Query time: ' . $result->getQueryTime();
htmlFooter();
开发者ID:swapnilphalak,项目名称:crawl-anywhere,代码行数:17,代码来源:2.2.2-delete-by-query.php


示例14: htmlHeader

<?php

require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// set the adapter to curl
$client->setAdapter('Solarium_Client_Adapter_Curl');
// get a select query instance
$query = $client->createSelect();
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: ' . $resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
    echo '<hr/><table>';
    // the documents are also iterable, to get all fields
    foreach ($document as $field => $value) {
        // this converts multivalue fields to a comma-separated string
        if (is_array($value)) {
            $value = implode(', ', $value);
        }
        echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
    }
    echo '</table>';
}
htmlFooter();
开发者ID:Bine0511,项目名称:RDF-Demo,代码行数:30,代码来源:6.1.3-curl-adapter.php


示例15: htmlHeader

<?php

require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a suggester query instance
$query = $client->createSuggester();
$query->setQuery('ap ip v');
//multiple terms
$query->setDictionary('suggest');
$query->setOnlyMorePopular(true);
$query->setCount(10);
$query->setCollate(true);
// this executes the query and returns the result
$resultset = $client->suggester($query);
echo '<b>Query:</b> ' . $query->getQuery() . '<hr/>';
// display results for each term
foreach ($resultset as $term => $termResult) {
    echo '<h3>' . $term . '</h3>';
    echo 'NumFound: ' . $termResult->getNumFound() . '<br/>';
    echo 'StartOffset: ' . $termResult->getStartOffset() . '<br/>';
    echo 'EndOffset: ' . $termResult->getEndOffset() . '<br/>';
    echo 'Suggestions:<br/>';
    foreach ($termResult as $result) {
        echo '- ' . $result . '<br/>';
    }
    echo '<hr/>';
}
// display collation
echo 'Collation: ' . $resultset->getCollation();
开发者ID:Bine0511,项目名称:RDF-Demo,代码行数:31,代码来源:2.6-suggester-query.php


示例16: htmlHeader

<?php

require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// search input string, this value fails without escaping because of the double-quote
$input = 'ATA "133';
// in this case phrase escaping is used (most common) but you can also do term escaping, see the manual
$helper = $query->getHelper();
$query->setQuery('features:' . $helper->escapePhrase($input));
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: ' . $resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
    echo '<hr/><table>';
    // the documents are also iterable, to get all fields
    foreach ($document as $field => $value) {
        // this converts multivalue fields to a comma-separated string
        if (is_array($value)) {
            $value = implode(', ', $value);
        }
        echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
    }
    echo '</table>';
}
htmlFooter();
开发者ID:realestateconz,项目名称:solarium,代码行数:31,代码来源:6.2-escaping.php


示例17: get_related

 /**
  * Get a collection of the laws most similar to the present law.
  */
 function get_related()
 {
     /*
      * The number of results to return. The default is 5.
      */
     if (!isset($this->num_results)) {
         $this->num_results = 5;
     }
     /*
      * Intialize Solarium.
      */
     $client = new Solarium_Client($GLOBALS['solr_config']);
     if ($client === FALSE) {
         return FALSE;
     }
     /*
      * Create a MoreLikeThis query instance.
      */
     $query = $client->createMoreLikeThis();
     /*
      * Note that we have to escape colons in this query.
      */
     $query->setQuery('section:' . str_replace(':', '\\:', $this->section_number));
     $query->setMltFields('text,tags,catch_line');
     $query->setMatchInclude(TRUE);
     $query->setStart(0)->setRows($this->num_results);
     /*
      * Execute the query and return the result.
      */
     $results = $client->select($query);
     /*
      * If our query fails.
      */
     if ($results === FALSE) {
         return FALSE;
     }
     /*
      * Create a new, blank object to store our related sections.
      */
     $related = new StdClass();
     /*
      * Iterate through the returned documents
      */
     $i = 0;
     foreach ($results as $document) {
         $law = new Law();
         $law->law_id = $document->id;
         $law->get_law();
         $related->{$i} = $law;
         $i++;
     }
     return TRUE;
 }
开发者ID:FreeLawFounders,项目名称:statedecoded,代码行数:56,代码来源:class.Law.inc.php


示例18: htmlHeader

<?php

require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a morelikethis query instance
$query = $client->createMoreLikeThis();
$query->setQuery('id:SP2514N');
$query->setMltFields('manu,cat');
$query->setMinimumDocumentFrequency(1);
$query->setMinimumTermFrequency(1);
$query->createFilterQuery('stock')->setQuery('inStock:true');
$query->setInterestingTerms('details');
$query->setMatchInclude(true);
// this executes the query and returns the result
$resultset = $client->select($query);
echo 'Document used for matching:<br/><table>';
foreach ($resultset->getMatch() as $field => $value) {
    // this converts multivalue fields to a comma-separated string
    if (is_array($value)) {
        $value = implode(', ', $value);
    }
    echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table><hr/>';
// display the total number of MLT documents found by solr
echo 'Number of MLT matches found: ' . $resultset->getNumFound() . '<br/><br/>';
echo '<b>Listing of matched docs:</b>';
// show MLT documents using the resultset iterator
foreach ($resultset as $document) {
开发者ID:swapnilphalak,项目名称:crawl-anywhere,代码行数:31,代码来源:2.3.1-mlt-query.php


示例19: htmlHeader

<?php

require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get an analysis document query
$query = $client->createAnalysisField();
$query->setShowMatch(true);
$query->setFieldName('cat,title');
$query->setFieldType('text_general');
$query->setFieldValue('Apple 60 GB iPod with Video Playback Black');
$query->setQuery('ipod');
// this executes the query and returns the result
$results = $client->analyze($query);
// show the results
foreach ($results as $result) {
    echo '<hr><h2>Result list: ' . $result->getName() . '</h2>';
    foreach ($result as $item) {
        echo '<h3>Item: ' . $item->getName() . '</h3>';
        $indexAnalysis = $item->getIndexAnalysis();
        if (!empty($indexAnalysis)) {
            echo '<h4>Index Analysis</h4>';
            foreach ($indexAnalysis as $classes) {
                echo '<h5>' . $classes->getName() . '</h5>';
                foreach ($classes as $result) {
                    echo 'Text: ' . $result->getText() . '<br/>';
                    echo 'Raw text: ' . $result->getRawText() . '<br/>';
                    echo 'Start: ' . $result->getStart() . '<br/>';
                    echo 'End: ' . $result->getEnd() . '<br/>';
                    echo 'Position: ' . $result->getPosition() . '<br/>';
开发者ID:swapnilphalak,项目名称:crawl-anywhere,代码行数:31,代码来源:2.4.2-analysis-field.php


示例20: htmlHeader

<?php

require 'init.php';
htmlHeader();
// create a client instance and get a select query instance
$client = new Solarium_Client($config);
// first an example manually defining dereferenced params
$query = $client->createSelect();
$helper = $query->getHelper();
$join = $helper->qparser('join', array('from' => 'manu_id', 'to' => 'id'), true);
$queryString = $join . 'id:1';
$query->setQuery($queryString);
$request = $client->createRequest($query);
// output resulting url with dereferenced params
echo urldecode($request->getUri()) . '<hr/>';
// this second example gives the exact same result, using the special join helper
$query = $client->createSelect();
$helper = $query->getHelper();
$join = $helper->join('manu_id', 'id', true);
$queryString = $join . 'id:1';
$query->setQuery($queryString);
$request = $client->createRequest($query);
echo urldecode($request->getUri());
htmlFooter();
开发者ID:Bine0511,项目名称:RDF-Demo,代码行数:24,代码来源:6.4-dereferenced-params.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Something类代码示例发布时间:2022-05-23
下一篇:
PHP Solar_Test类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap