from couchbase.cluster import Cluster, ClusterOptions from couchbase.auth import PasswordAuthenticator from couchbase.exceptions import CouchbaseException import couchbase.search as search
try: result = cluster.search_query( “travel-sample-index”, search.QueryStringQuery(“swanky”))
for row in result.rows(): print(“Found row: {}“.format(row))
print(“Reported total rows: {}“.format( result.metadata().metrics.total_rows))
except CouchbaseException as ex: import traceback traceback.print_exc()
Exception
Error:'function' object has no attribute 'total_rows'
I could not figure out how to get the total_rows or other metrics in the SDK 4.x.
Observations
metrics is being interpreted as a method instead of property.
And the method metrics() returns None.
Environment
None
Gerrit Reviews
None
Release Notes Description
None
Activity
Nithish Raghunandanan August 2, 2022 at 8:20 AM
Thank you !
Jared Casey August 1, 2022 at 6:45 PM
Metrics are now available for search results. Tests have been added to verify the SearchResult, SearchMetadata and SearchMetrics objects.
Jared Casey August 1, 2022 at 2:50 PM
Hi - We should be able to have this corrected in the 4.0.3 release (should happen later this week). In order to keep consistent with the rest of the streaming APIs, access to metadata, metrics, etc. will be with method invocations. Will look to get the documentation update this week as well.
Example once changes are in play:
Fixed
Pinned fields
Click on the next to a field label to start pinning.
In SDK 3.x, the Search Metrics can be fetched from the metrics property directly.
In SDK 4.x, the metrics are not available in the same way anymore.
Code Sample:
Exception
I could not figure out how to get the total_rows or other metrics in the SDK 4.x.
Observations
metrics is being interpreted as a method instead of property.
And the method metrics() returns None.