Today, I downloaded the last version of Couchbase CE and the JDK client and I tried this simple code (it’s Groovy code) on the beer sample bucket:
package couchbase.beer
import com.couchbase.client.java.Cluster
import com.couchbase.client.java.CouchbaseCluster
import com.couchbase.client.java.query.N1qlQuery
import com.couchbase.client.java.view.ViewQuery
import static com.couchbase.client.java.query.Select.select
import static com.couchbase.client.java.query.dsl.Expression.i
def cluster = CouchbaseCluster.create()
def beerBucket = cluster.openBucket('beer-sample')
def oneBeer = beerBucket.get('21st_amendment_brewery_cafe')
assert oneBeer
println oneBeer
println "==================> HERE <=================="
def result = beerBucket
.query(N1qlQuery.simple(select("*").from(i('beer-sample')).limit(10)))
println "SIZE: ${result.rows().size()}"
cluster.disconnect()
The first query by key works well. I retrieve a JSON object. But when I code the N1QL query, I’ve no result. For information, the code above comes from the couchbase developer site.
Thanks for any help.