php-doc-en/reference/solr/solrinputdocument/addchilddocument.xml
Omar Shaban eda8c2e0ce SolrChild Documents
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@340984 c90b9560-bf6c-de11-be94-00142212c4b1
2016-11-13 13:26:56 +00:00

162 lines
4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="solrinputdocument.addchilddocument" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SolrInputDocument::addChildDocument</refname>
<refpurpose>Adds a child document for block indexing</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>SolrInputDocument::addChildDocument</methodname>
<methodparam><type>SolrInputDocument</type><parameter>child</parameter></methodparam>
</methodsynopsis>
<para>
Adds a child document to construct a document block with nested documents.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>child</parameter></term>
<listitem>
<para>
A <type>SolrInputDocument</type> object.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SolrIllegalArgumentException</classname> on failure.
</para>
<para>
Throws <classname>SolrException</classname> on internal failure.
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>SolrInputDocument::addChildDocument</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
include "bootstrap.php";
$options = array
(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
'path' => SOLR_SERVER_STORE_PATH,
);
$client = new SolrClient($options);
$product = new SolrInputDocument();
$product->addField('id', 'P-BLACK');
$product->addField('cat', 'tshirt');
$product->addField('cat', 'polo');
$product->addField('content_type', 'product');
$small = new SolrInputDocument();
$small->addField('id', 'TS-BLK-S');
$small->addField('content_type', 'sku');
$small->addField('size', 'S');
$small->addField('inventory', 100);
$medium = new SolrInputDocument();
$medium->addField('id', 'TS-BLK-M');
$medium->addField('content_type', 'sku');
$medium->addField('size', 'M');
$medium->addField('inventory', 200);
$large = new SolrInputDocument();
$large->addField('id', 'TS-BLK-L');
$large->addField('content_type', 'sku');
$large->addField('size', 'L');
$large->addField('inventory', 300);
// add child documents
$product->addChildDocument($small);
$product->addChildDocument($medium);
$product->addChildDocument($large);
// add product document block to the index
$updateResponse = $client->addDocument(
$product,
true, // overwrite if the document exists
10000 // commit within 10 seconds
);
print_r($updateResponse->getResponse());
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
SolrObject Object
(
[responseHeader] => SolrObject Object
(
[status] => 0
[QTime] => 5
)
)
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><methodname>SolrInputDocument::addChildDocuments</methodname></member>
<member><methodname>SolrInputDocument::hasChildDocuments</methodname></member>
<member><methodname>SolrInputDocument::getChildDocuments</methodname></member>
<member><methodname>SolrInputDocument::getChildDocumentsCount</methodname></member>
</simplelist>
</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
-->