Search code examples
javacouchbasecouchbase-viewjava-client

Java: How to retrieve all documents from specific bucket of couchbase server?


I am trying to retrieve all documents from my local couchbase server. I have created one bucket as named "student" but it just show opened bucket and give build successful message nothing happen beyond that,i am expecting list of all documents.

Cluster cluster = CouchbaseCluster.create();
        Bucket bucket = cluster.openBucket("student");
        N1qlQueryResult result = bucket.query(N1qlQuery.simple("SELECT * FROM `student`"));

        for (N1qlQueryRow row : result) {
            String Name = row.value().getString("name");
            System.out.println(Name);
        }

Solution

  • It just sounds like you want to retrieve all documents from buckets created on local server You can do one thing refer link it might be helpful for you after following all steps just run following command on terminal

    create primary index on `beer-sample`;