Added an example

-- 
Provided by Nicolas Wallace (nwallace@fyberstudios.com)

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@325706 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2012-05-16 05:11:57 +00:00
parent d39f1fe8ad
commit 186dbabeb3
2 changed files with 101 additions and 0 deletions

View file

@ -42,6 +42,63 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>SolrQuery::addFacetField</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
$options = array
(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
);
$client = new SolrClient($options);
$query = new SolrQuery();
$query->setQuery($query);
$query->addField('price')->addField('color');
$query->setFacet(true);
$query->addFacetField('price')->addFacetField('color');
$query_response = $client->query($query);
$response = $query_response->getResponse();
print_r($response['facet_counts']['facet_fields']);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
SolrObject Object
(
[color] => SolrObject Object
(
[blue] => 20
[green] => 100
)
)
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -42,6 +42,50 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>SolrQuery::addFilterQuery</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
$options = array
(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
);
$client = new SolrClient($options);
$query = new SolrQuery();
$query->setQuery($query);
$query->addFilterQuery('color:blue,green');
$query_response = $client->query($query);
$response = $query_response->getResponse();
print_r($response['facet_counts']['facet_fields']);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
&fq=color:blue,green
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file