Couchbase Export few Documents

Requirement : Export few documents from one server of couchbase to another server. Basically bucket which has 1000 documents in Development Environment and take the selected document using a N1QL query (say the result to be 300 documents). Transfer these 300 documents to the UAT environment.
Is it possible?

Tried with couchbase Backup tool and it worked for single document. But how to append multiple documents? Or is it possible to give the n1ql query in the exporting options?

may be you can use curl() function (after CB 4.6.0) to get data from N1QL REST Query to insert into your server.
FYI

thanks @atom_yang.

Hi @Arunachalam,
The CURL() function in N1QL can surely help here, but that is coming in CB5.0. You can try it with developer builds available https://www.couchbase.com/downloads

Following blogs provide more details, and you can use it with INSERT-SELECT


https://blog.couchbase.com/developer-release-curl-n1ql/

If you are using 4.6, you can try the new import/export tool:
https://developer.couchbase.com/documentation/server/4.6/tools/cbimport.html

hth,
-Prasad

Thanks. I am getting the below error while inserting into the bucket.

insert into test(key k, value _v)
select meta().id _k, _v from test_1_v where id=“00001430-393”

Error is ,
“errors”: [
{
“code”: 5070,
“msg”: “Cannot INSERT non-string key Missing field or index k. of type value.missingValue.”.

How to resolve this? What mistake am i making? I am using 4.6.

try this

insert into test(key k, value _v)
select meta().id k, test1_v AS _v from test1_v where id="00001430-393"

Thanks. It worked. I will wait for Release 5 for using Curl command to transfer specific data from one server to another

Hi I have one document which was already existed in Couchbase DB. In the bucket the “ID ==abc”. And I want to generate same document, but ID should be “abc1”. I don’t understand how to use INSERT SELECT query. Can you please explain.

Use INSERT INTO SELECT statement. Example 8, 13-15 at https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/insert.html