php solr 查询

2019-03-27 01:04|来源: 网路

$options = array
(
  'hostname' => 'localhost',
  'port' => 8080,
  'path' => 'solr/test'
);

$client = new SolrClient($options);

$query = new SolrQuery();

$query->setQuery('title:今日');

$query->setStart(0);

$query->setRows(50);

$query->addField('id')->addField('title');

$query_response = $client->query($query);

$response = $query_response->getResponse();

print_r($response);

 

结果如下

SolrObject Object ( [responseHeader] => SolrObject Object ( [status] => 0 [QTime] => 0 [params] => SolrObject Object ( [fl] => id,title [indent] => on [start] => 0 [q] => title:今日 [wt] => xml [rows] => 50 [version] => 2.2 ) ) [response] => SolrObject Object ( [numFound] => 2 [start] => 0 [docs] => Array ( [0] => SolrObject Object ( [id] => 324 [title] => 聚划算今日最大牌团购 ) [1] => SolrObject Object ( [id] => 333 [title] => 聚划算今日最大牌团购 ) ) ) )

 

API 参考

http://www.php.net/manual/zh/class.solrclient.php


转自:http://www.cnblogs.com/sidesky/p/3243794

相关问答

更多

检索驱动程序分配的样本数(Retrieve number of samples allocated by driver)

您可以通过从glGetTexLevelParameteriv查询GL_TEXTURE_SAMPLES来glGetTexLevelParameteriv为特定纹理分配的样本数。 不,我刚才没有将其插入页面。 不要关注该页面的编辑历史 ; 它总是在那里。 You can get the number of samples allocated for a particular texture by querying GL_TEXTURE_SAMPLES from glGetTexLevelParame

仅按月和年份分组日期(Group dates by only month and year)

尝试这个 SELECT DATE_FORMAT(duedate,'%M %Y') duedatemonth, COUNT(*) count FROM Table1 GROUP BY year(duedate), MONTH(duedate) 在这里演示 将输出: DUEDATEMONTH COUNT January 2012 2 February 2012 2 January 2013 1 March 20

如何通过表单输入添加新表和列(How to add new table and column by form input)

尝试这个 <?php // Create connection mysql_connect("localhost","root","","test") OR die("Server Connection error"); mysql_select_db("test") OR die("DB error"); $category = "category"; // sql to create table $sql = "CREATE TA

拖动时获取谷歌地图中心的纬度和经度(Get Latitude and Longitude of the center in google map when dragged)

考虑使用idle事件而不是dragend 平移或缩放后地图变为空闲时会触发此事件。 Consider to use idle event instead dragend This event is fired when the map becomes idle after panning or zooming.

php SimpleXMLelement解析具有多个“潜在”属性的XML标记(php SimpleXMLelement parsing XML tags with multiple 'potential' attributes)

请注意,我没有使用SimpleXML ,因为imho DOMDocument只是太好了,而且更强大。 自PHP5起, DOMDocument和DOMXPath都可用。 我创建了一个简单的解析器类,它解析提供的文档以获得不同样式的条件: class AIMLParser { public function parse($data) { $internalErrors = libxml_use_internal_errors(true); $dom

相关文章

更多

最近更新

更多