DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How are you handling the data revolution? We want your take on what's real, what's hype, and what's next in the world of data engineering.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

SBOMs are essential to circumventing software supply chain attacks, and they provide visibility into various software components.

Related

  • From OCR Bottlenecks to Structured Understanding
  • How I Built an AI Portal for Document Q and A, Summarization, Transcription, Translation, and Extraction
  • How to Merge HTML Documents in Java
  • Google Cloud Document AI Basics

Trending

  • Effective Exception Handling in Java and Spring Boot Applications
  • When Incentives Sabotage Product Strategy
  • Self-Supervised Learning Techniques
  • Top Load Balancing Algorithms: Choosing the Right Strategy

Copying Documents Between Buckets in Couchbase

Want to copy your data from one Couchbase bucket to another? It just takes a bit of N1QL.

By 
Matthew Groves user avatar
Matthew Groves
·
Aug. 24, 16 · Interview
Likes (3)
Comment
Save
Tweet
Share
5.2K Views

Join the DZone community and get the full member experience.

Join For Free

when i’m at a user group or conference, people often come up to me afterwards with good questions. this is a great way for me to get blog post ideas: if they have a question, chances are lots of other people have the same one. it’s also a great way for me to get to know couchbase better.

this post is for one of those questions: can i copy documents from one bucket to another ?

yes! in fact, if you’ve done this sort of thing in sql, then you are not too far from already knowing the answer.

fire buckets image licensed through creative commons via paul harrop - http://www.geograph.org.uk/photo/2666296

there are command line tools to backup / restore a bucket, but for this post, i’m going to assume that what you want is to make a copy of some documents from bucket a into bucket b.

it’s as easy as using a n1ql insert .

start by creating a n1ql select to get the documents you want out of the first bucket. i’m going to show a very simplified select that gets all the documents from my default bucket. if you only want a subset, you can use a where clause.

select meta().id _k, _v
from `default` _v


since we’re copying to another bucket, we need both the key and the document itself. this query selects the document key using the meta() function and selects the document using a _v alias.

next, i’ll create an insert to put these selected documents into another bucket, which i called target .

insert into `target` (key _k, value _v)
select meta().id _k, _v
from `default` _v


an insert needs a key and a value. i have those from the select . all done.

Document

Published at DZone with permission of Matthew Groves, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • From OCR Bottlenecks to Structured Understanding
  • How I Built an AI Portal for Document Q and A, Summarization, Transcription, Translation, and Extraction
  • How to Merge HTML Documents in Java
  • Google Cloud Document AI Basics

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: