©
本文档使用
php.cn手册 发布
(PECL solr >= 0.9.2)
SolrClient::query — Sends a query to the server
$query
)Sends a query to the server.
query
A SolrParams object. It is recommended to use SolrQuery for advanced queries.
Returns a SolrQueryResponse object on success and throws an exception on failure.
Throws SolrClientException if the client had failed, or there was a connection issue.
Throws SolrServerException if the Solr Server had failed to satisfy the query.
Example #1 SolrClient::query() example
<?php
$options = array
(
'hostname' => 'localhost' ,
'login' => 'username' ,
'password' => 'password' ,
'port' => '8983' ,
);
$client = new SolrClient ( $options );
$query = new SolrQuery ();
$query -> setQuery ( 'lucene' );
$query -> setStart ( 0 );
$query -> setRows ( 50 );
$query -> addField ( 'cat' )-> addField ( 'features' )-> addField ( 'id' )-> addField ( 'timestamp' );
$query_response = $client -> query ( $query );
$response = $query_response -> getResponse ();
print_r ( $response );
?>
以上例程的输出类似于:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|