arangodb / arangodb-php

PHP ODM for ArangoDB
https://www.arangodb.com
Apache License 2.0
183 stars 43 forks source link

getFullCount() returns NULL #187

Closed milko closed 7 years ago

milko commented 8 years ago

I am trying to get the cursor full count excluding the limit, when I call the getFullCount() I receive NULL. I do the following:

$result = $collectionHandler->byExample( $collection->getId(), ["surname" => "Škofič"], ["skip" => 0, "limit" => 10] );

$result->getCount() returns 10 correctly. $result->getFullCount() returns NULL.

Did I miss some conficuration options or is it an issue?

Thanks! Milko

aguilera51284 commented 8 years ago

i have the same problem.

frankmayer commented 7 years ago

It's not Arango-PHP's problem... I just curl'd Arango with the following line (having interrupted the unit tests of ArangoDP-PHP directly after the collection was filled with the needed documents):

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"collection":"ArangoDB_PHP_TestSuite_TestCollection_01","example":{ "name": "john"},"options":{"fullCount":true}}' 'http://localhost:8529/_db/_system/_api/simple/by-example'

Response Body { "result": [ { "_key": "345017227", "_id": "ArangoDB_PHP_TestSuite_TestCollection_01/345017227", "_rev": "345017227", "name": "john" } ], "hasMore": false, "count": 1, "error": false, "code": 201 }

The extra/stats subdocument, which contains fullCount, should be there, but it's not for simple queries. It is there for AQL queries, though. @jsteemann I think this is a problem with ArangoDB's simple query endpoint.

frankmayer commented 7 years ago

Just revisited this... Don't know if it was a problem after all. But the important thing to note here, is that it will only return fullCount if the query has a LIMIT clause and it is actually used. See docs here: https://docs.arangodb.com/3.1/HTTP/AqlQueryCursor/AccessingCursors.html

Note that setting the option will disable a few LIMIT optimizations and may lead to more documents being processed, and thus make queries run longer. Note that the fullCount attribute will only be present in the result if the query has a LIMIT clause and the LIMIT clause is actually used in the query.

Closing this one now. If there should be any other issue with this, feel free to reopen.