php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #70953 Support nested documents parsing
Submitted: 2015-11-22 11:32 UTC Modified: 2015-12-01 23:51 UTC
From: omars@php.net Assigned: omars (profile)
Status: Closed Package: solr (PECL)
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: omars@php.net
New email:
PHP Version: OS:

 

 [2015-11-22 11:32 UTC] omars@php.net
Description:
------------
Support responses with nested documents

Query Example: q=*:*&parentFilter=content_type:parentDocument&fq={!parent which=$parentFilter}&fl=*,[child parentFilter=$parentFilter]&start=0&rows=50

example response:
<response>

  <result name="response" numFound="3" start="0">
    <doc>
      <str name="id">parent_1</str>
      <doc>
        <str name="id">CHILD_1_1</str>
      </doc>
    </doc>
    <doc>
      <str name="id">parent_2</str>
      <doc>
        <str name="id">CHILD_2_1</str>
      </doc>
      <doc>
        <str name="id">CHILD_2_2</str>
      </doc>
    </doc>
    <doc>
      <str name="id">not_a_parent_1</str>
    </doc>
  </result>
</response>

Test script:
---------------
$fixtureXml = '<response>

  <result name="response" numFound="3" start="0">
    <doc>
      <str name="id">parent_1</str>
      <doc>
        <str name="id">CHILD_1_1</str>
      </doc>
    </doc>
    <doc>
      <str name="id">parent_2</str>
      <doc>
        <str name="id">CHILD_2_1</str>
      </doc>
      <doc>
        <str name="id">CHILD_2_2</str>
      </doc>
    </doc>
    <doc>
      <str name="id">not_a_parent_1</str>
    </doc>
  </result>
</response>';

$response = SolrUtils::digestXmlResponse($fixtureXml);

print_r($response);


Expected result:
----------------
SolrObject Object
(
    [response] => SolrObject Object
        (
            [numFound] => 3
            [start] => 0
            [docs] => Array
                (
                    [0] => SolrObject Object
                        (
                            [id] => parent_1
                            [_childDocuments_] => Array
                                (
                                    [0] => SolrObject Object
                                        (
                                            [id] => CHILD_1_1
                                        )

                                )

                        )

                    [1] => SolrObject Object
                        (
                            [id] => parent_2
                            [_childDocuments_] => Array
                                (
                                    [0] => SolrObject Object
                                        (
                                            [id] => CHILD_2_1
                                        )

                                    [1] => SolrObject Object
                                        (
                                            [id] => CHILD_2_2
                                        )

                                )

                        )

                    [2] => SolrObject Object
                        (
                            [id] => not_a_parent_1
                        )

                )

        )

)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-22 12:00 UTC] omars@php.net
-Assigned To: +Assigned To: omars
 [2015-12-01 23:51 UTC] omars@php.net
-Status: Assigned +Status: Closed
 [2015-12-01 23:51 UTC] omars@php.net
resolved since: 2.3.0
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 10:01:34 2025 UTC