Export data from bucket

Hi there,

I wonder if there’s a way to export some data from a bucket with a query from a bucket in server 6.6? all we need is export a certain type of documents, not the whole bucket. I know there’s cbexport, it seems like it can only export the whole bucket not able to use with query? Or I am wrong about that? thanks in advance.

Why not just run the query you want and save the output ? You could run it through a tool like ‘jq’, e.g.

curl -su Administrator:pword http://localhost:8093/query/service -d 'statement=select a,b,c from default where e != f'|jq .results > output.json

HTH.

Thank you @dh for the quick response. does the localhost needs to be the query node? will this command cause heavy load on the server with about 86953 documents, average in size, 18585k.

It can be any query node you have access to.
Are you intending to export all 1.5 TiB of data? If so, yes, it probably will have some impact.
If your query is a small sub-set, then it shouldn’t be too great. Of course most of the load will be in selecting the documents, so if that’s efficient (i.e. index supports your where clause and you don’t add unnecessary clauses such as ORDER BY) the load can be minimised.
Depending on your filtering criteria you could perhaps use batches - following standard pagination techniques - to spread the load a bit over time.

Ref: https://www.couchbase.com/blog/offset-keyset-pagination-n1ql-query-couchbase/

HTH.