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

相关问答

更多

关于solr的分组查询

public static Map<String, Integer> queryByGroup(String qStr,String groupField,String sortField,boolean asc,Integer pageSize,Integer pageNum){ Map<String, Integer> rmap = new LinkedHashMap<String, Integer>(); try { SolrServer server = ...

solr 使用java jdbc查询

看到了空指针 看看 count(sequence_d) 这个值,改为* 看看报不报错,不报错就是count(sequence_d)有问题

在solr查询中使用OR和NOT(using OR and NOT in solr query)

我不知道为什么这不工作,但这是逻辑上相同的,它的工作: -(myField:superneat AND -myOtherField:somethingElse) 也许这与在查询中定义相同的字段两次有关 尝试在solr-user组中询问,然后在这里发回最后的答案! I don't know why that doesn't work, but this one is logically equivalent and it does work: -(myField:superneat AND -my ...

加快SOLR搜索(Speeding up SOLR search)

你也可以检查下面: - SolrPerformanceFactors ImproveSearchingSpeed ImproveIndexingSpeed SolrCaching 在-七致命-罪-OF-的Solr You can also check below :- SolrPerformanceFactors ImproveSearchingSpeed ImproveIndexingSpeed SolrCaching the-seven-deadly-sins-of-solr

在PHP中如何在Apache Solr中更新文档(In PHP how to update a document in Apache Solr)

在@Random的一些指示后,我最终得到了它。 这就是我设法做到的方式: include "bootstrap.php"; $options = array ( 'hostname' => SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, ); $client = new Solr ...

相关文章

更多

最近更新

更多