How to use Couchbase function in index creation in Python? -


i'm trying create inverted index on date field. works in couchbase admin console, i'm getting error in python code. i'm doing wrong python, not find examples on using function index creation in python. here working n1ql:

create index `mytabenter code herele_date` on `mytable`(-tonumber(`date`)); 

here broken python code:

cb = bucket('couchbase://localhost/mytable', password='passw0rd') cb.bucket_manager().create_n1ql_index('mytable_date_desc', fields=[-tonumber('date_desc')], defer=true, ignore_exists=true) 

function -tonumber generate error "unresolved reference"/ "nameerror: name 'tonumber' not defined".

what right way of creating such index function?

you need escape tonumber it's n1ql defined function , not in python sdk directly; following example should work:

manager.create_n1ql_index( 'mytable_date_desc', fields=['(-tonumber(`date`))'], defer=true, ignore_exists=true)


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -