php-doc-en/reference/solr/solrclient/query.xml

175 lines
4.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="solrclient.query" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SolrClient::query</refname>
<refpurpose>Sends a query to the server</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>SolrQueryResponse</type><methodname>SolrClient::query</methodname>
<methodparam><type>SolrParams</type><parameter>query</parameter></methodparam>
</methodsynopsis>
<para>
Sends a query to the server.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>query</parameter></term>
<listitem>
<para>
A <type>SolrParams</type> object. It is recommended to use <type>SolrQuery</type> for advanced queries.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a <type>SolrQueryResponse</type> object on success and throws an exception on failure.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SolrClientException</classname> if the client had failed, or there was a connection issue.
</para>
<para>
Throws <classname>SolrServerException</classname> if the Solr Server had failed to satisfy the query.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>SolrClient::query</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?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);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
SolrObject Object
(
[responseHeader] => SolrObject Object
(
[status] => 0
[QTime] => 3
[params] => SolrObject Object
(
[fl] => cat,features,id,timestamp
[indent] => on
[start] => 0
[q] => lucene
[wt] => xml
[version] => 2.2
[rows] => 50
)
)
[response] => SolrObject Object
(
[numFound] => 1
[start] => 0
[docs] => Array
(
[0] => SolrObject Object
(
[id] => SOLR1000
[cat] => Array
(
[0] => software
[1] => search
)
[features] => Array
(
[0] => Advanced Full-Text Search Capabilities using Lucene
[1] => Optimized for High Volume Web Traffic
[2] => Standards Based Open Interfaces - XML and HTTP
[3] => Comprehensive HTML Administration Interfaces
[4] => Scalability - Efficient Replication to other Solr Search Servers
[5] => Flexible and Adaptable with XML configuration and Schema
[6] => Good unicode support: héllo (hello with an accent over the e)
)
)
)
)
)
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->