php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72125 SolrQuery::setGroupLimit doesn't work, doesn't add group.limit to query string
Submitted: 2016-04-28 22:19 UTC Modified: 2016-05-06 18:15 UTC
From: mail at danhofmann dot com Assigned:
Status: Not a bug Package: solr (PECL)
PHP Version: 7.0.5 OS: CentOS release 6.4 (Final)
Private report: No CVE-ID: None
 [2016-04-28 22:19 UTC] mail at danhofmann dot com
Description:
------------
---
From manual page: http://www.php.net/solrquery.getgrouplimit
---


Using the setGroupLimit() function of the SolrQuery object does not actually add the group.limit parameter to the query string being sent to the solr server.

As a work around, I have to manually specify it using setParam()


i.e.  setParam('group.limit', 200);

Test script:
---------------
const SOLR_QUERY_ALL = '*:*';

// ...

$this->solrQuery = new SolrQuery(self::SOLR_QUERY_ALL);
$this->solrClient = new SolrClient('catalog');

// ...
$this->solrQuery->setGroup(true);
$this->solrQuery->setGroupNGroups(true); 
$this->solrQuery->setGroupMain(false);
$this->solrQuery->getGroupLimit(200); // DOES NOT ACTUALLY DO ANYTHING!

// ...

$query_response = $this->solrClient->query($this->solrQuery);  
$this->response = get_object_vars($query_response->getResponse()); 

print_r($this->response);

Expected result:
----------------
Array
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 75
            [params] => (...
                        )

                    [indent] => on
                    [group.limit] => 200
                    [start] => 0
                    [facet.missing] => true
                    [fq] => Array
                        (
                            ...
                        )

                    [rows] => 25
                    [group.ngroups] => true
                    [version] => 2.2
                    [q] => *:*
                    [facet.limit] => -1
                    [group.main] => false
                    [facet.threads] => 6
                    [facet.mincount] => 1
                    [wt] => xml
                    [facet] => true
                    [group.field] => product_id
                    [group] => true
                )

        )

Actual result:
--------------
Array
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 75
            [params] => (...
                        )

                    [indent] => on
                    [start] => 0
                    [facet.missing] => true
                    [fq] => Array
                        (
                            ...
                        )

                    [rows] => 25
                    [group.ngroups] => true
                    [version] => 2.2
                    [q] => *:*
                    [facet.limit] => -1
                    [group.main] => false
                    [facet.threads] => 6
                    [facet.mincount] => 1
                    [wt] => xml
                    [facet] => true
                    [group.field] => product_id
                    [group] => true
                )

        )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-06 09:40 UTC] omars@php.net
-Status: Open +Status: Not a bug
 [2016-05-06 09:40 UTC] omars@php.net
You are calling the getter SolrQuery::getGroupLimit(200) instead of SolrQuery::setGroupLimit(200)
 [2016-05-06 18:15 UTC] mail at danhofmann dot com
Confirmed, I was mistakenly using the getter method.
not a bug.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 08:01:23 2020 UTC