Unable to open bucket in cluster


I am trying to use FTS using python sdk and following the documentation provided at: Full Text Search using the SDK | Couchbase Docs

but looks like I am unable to open a bucket on cluster.

Here is the piece of code that I am trying to run

cluster = Cluster('<connection-string>', ClusterOptions(PasswordAuthenticator('<username>', '<password>')))
result = cluster.search_query("<index-name>", QueryStringQuery("query"))

Upon executing I am getting below error:

couchbase.exceptions.SearchException: <Cluster operation on bucket failed, inner_cause=<No buckets opened on cluster>>

Can someone pls help if I am doing something wrong?

@dev-agr Can you please look here Couchbase Playground? It gives you options to connect to a bucket. If you still running to a problem, let me know I will try to get a working sample

Thanks for the reply, Raju!
Yes, I am able to connect to a bucket but the issue lies upon using the cluster object for search_query method (as shown above).

@dev-agr Try this


import sys

from couchbase.cluster import Cluster, ClusterOptions
from couchbase_core.cluster import PasswordAuthenticator
from couchbase.search import QueryStringQuery, SearchQuery, SearchOptions, PrefixQuery, SortScore, TermFacet
from couchbase.mutation_state import MutationState

print:(“Reached here”)
pa = PasswordAuthenticator(‘username’, ‘password’)

cluster = Cluster(‘couchbase://’, ClusterOptions(pa))
bucket = cluster.bucket(‘travel-sample’)

print:(“Reached here”)
result = cluster.search_query(“index”, PrefixQuery(“airports-”), SearchOptions(fields=[“field-1”]))

for row in result.rows():
 print("Score: {}".format(row.score()))
 print("Document Id: {}".format(row.id()))

# Also print fields that are included in the query

print(“exception:”, sys.exc_info()[0])

Hi @raju ,

The code snippet that you shared - is that supposed to be working?
Because I am getting below exception when upon iterating through result.
Ran it on couchbase playground.

<RC=0x41D[LCB_ERR_HTTP (1053)], HTTP Request failed. Examine 'objextra' for full result, Results=1, C Source=(src/pycbc_http.c,206), OBJ=ViewResult<rc=0x41D[LCB_ERR_HTTP (1053)], value={'error': 'rest_auth: preparePerms, err: index not found', 'request': {'ctl': {'timeout': 75000}, 'indexName': 'index', 'query': {'prefix': 'airports-'}}, 'status': 'fail'}, http_status=0, tracing_context=0, tracing_output=None>, Context={'http_response_code': 400, 'error_message': 'rest_auth: preparePerms, err: index not found', 'index_name': 'index', 'query': '', 'params': '', 'http_response_body': '', 'endpoint': '', 'type': 'SearchErrorContext'}, Tracing Output={":nokey:0": null}>

@dev-agr Of course it is working. Please make sure you create the Search Index