NotSupportedError when trying to build primary index in N1QL in Couchbase Python SDK

1.5k views Asked by At

I'm trying to get into the new N1QL Queries for Couchbase in Python. I got my database set up in Couchbase 4.0.0.

My initial try was to retreive all documents like this:

from couchbase.bucket import Bucket

bucket = Bucket('couchbase://localhost/dafault')

rv = bucket.n1ql_query('CREATE PRIMARY INDEX ON default').execute()
for row in bucket.n1ql_query('SELECT * FROM default'):
    print row

But this produces a OperationNotSupportedError:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2357, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1777, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Users/my_user/python_tests/test_n1ql.py", line 9, in <module>
    rv = bucket.n1ql_query('CREATE PRIMARY INDEX ON default').execute()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/couchbase/n1ql.py", line 215, in execute
    for _ in self:
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/couchbase/n1ql.py", line 235, in __iter__
    self._start()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/couchbase/n1ql.py", line 180, in _start
    self._mres = self._parent._n1ql_query(self._params.encoded)
couchbase.exceptions.NotSupportedError: <RC=0x13[Operation not supported], Couldn't schedule n1ql query, C Source=(src/n1ql.c,82)>

Here the version numbers of everything I use:

Couchbase Server: 4.0.0
couchbase python library: 2.0.2
cbc: 2.5.1
python: 2.7.8
gcc: 4.2.1

Anyone an idea what might have went wrong here? I could not find any solution to this problem up to now.

There was another ticket for node.js where the same issue happened. There was a proposal to enable n1ql for the specific bucket first. Is this also needed in python?

2

There are 2 answers

0
Mark Nunberg On BEST ANSWER

It would seem you didn't configure any cluster nodes with the Query or Index services. As such, the error returned is one that indicates no nodes are available.

0
ram dhakne On

I also got similar error while trying to create primary index.

    Create a primary index...
Traceback (most recent call last):
  File "post-upgrade-test.py", line 45, in <module>
    mgr.n1ql_index_create_primary(ignore_exists=True)
  File "/usr/local/lib/python2.7/dist-packages/couchbase/bucketmanager.py", line 428, in n1ql_index_create_primary
    '', defer=defer, primary=True, ignore_exists=ignore_exists)
  File "/usr/local/lib/python2.7/dist-packages/couchbase/bucketmanager.py", line 412, in n1ql_index_create
    return IxmgmtRequest(self._cb, 'create', info, **options).execute()
  File "/usr/local/lib/python2.7/dist-packages/couchbase/_ixmgmt.py", line 160, in execute
    return [x for x in self]
  File "/usr/local/lib/python2.7/dist-packages/couchbase/_ixmgmt.py", line 144, in __iter__
    self._start()
  File "/usr/local/lib/python2.7/dist-packages/couchbase/_ixmgmt.py", line 132, in _start
    self._cmd, index_to_rawjson(self._index), **self._options)
couchbase.exceptions.NotSupportedError: <RC=0x13[Operation not supported], Couldn't schedule ixmgmt operation, C Source=(src/ixmgmt.c,98)>

Adding query and index node to the cluster solved the issue.