couchbase

N1QL Concatenate many children rows into single string

可紊 提交于 2019-12-11 11:45:48
问题 Consider in Couchbase I have a person database, with 3 documents: Person A Child AA Grand AAA Grand AAB Child AB Grand ABA Grand ABB Person B Person C Child CA Child CB Grand CBA Is there an easy way to turn this into following results using N1QL? I am trying to display each person with their grand children displayed into strings? Person A, Grand: "AAA, AAB, ABA, ABB" Person B, Grand: "" Person C, Grand: "CBA" 回答1: You can do the following: SELECT p.name AS p, ENCODE_JSON(ARRAY_AGG(g.name))

Can I use TTL on members on couchbase documents?

岁酱吖の 提交于 2019-12-11 08:51:33
问题 I'm designing my back-end. I have a json array/queue/something which I only need any data that is at most 2 weeks old, that is continuously appended to. I only want to delete from this "queue", but not the container document. Can I use TTL for this, or does TTL only work for whole documents? Is there a better way to do this? Should I store them in per-day or per-hour arrays as separate documents instead? Running couchbase 2.2. 回答1: TTL in Couchbase only applies to whole documents, it's not

How to connect to Couchbase server 4.0(Beta) N1QL in windows?

雨燕双飞 提交于 2019-12-11 08:49:13
问题 I have just installed Couchbase Server 4.0(beta) and try to run N1QL Query, but could not connect it. When I try to run cbq-engine.exe -couchbase http://localhost:8091/ The command prompt closed automatically. When try to use cb.exe -engine=http://localhost:8091/ It also does not work. Is it bug? How to connect it? (I am running cbq.exe from bin directory of installation) 回答1: As documented in the Running your first N1QL query section of the Couchbase Server manual the port the cbq needs to

couchbase N1ql query select with non-group by fields

こ雲淡風輕ζ 提交于 2019-12-11 07:27:39
问题 I am new to couchbase and I have been going through couchbase documents and other online resources for a while but I could't get my query working. Below is the data structure and my query: Table1: { "jobId" : "101", "jobName" : "abcd", "jobGroup" : "groupa", "created" : " "2018-05-06T19:13:43.318Z", "region" : "dev" }, { "jobId" : "102", "jobName" : "abcd2", "jobGroup" : "groupa", "created" : " "2018-05-06T22:13:43.318Z", "region" : "dev" }, { "jobId" : "103", "jobName" : "abcd3", "jobGroup"

Couchbase: How to copy data from bucket to another?

寵の児 提交于 2019-12-11 07:19:55
问题 I have a bucket ( Bucket1 ) that I need to delete, and move its documents to another bucket ( Bucket2 ). What is the best way achieving this? I'm using version 4.5. 回答1: The cbtransfer tool should be able to do the data transfer you need. https://docs.couchbase.com/server/6.0/cli/cbtransfer-tool.html bucket-delete can be used to delete a bucket once you are finished with it. https://docs.couchbase.com/server/6.0/cli/cbcli/couchbase-cli-bucket-delete.html 来源: https://stackoverflow.com

N1QL : Find latest status from an array

人盡茶涼 提交于 2019-12-11 07:15:23
问题 I have a document of type 'User' as- { "id":"User-1", "Name": "Kevin", "Gender":"M", "Statuses":[ { "Status":"ONLINE", "StatusChangedDate":"2017-11-01T17:12:00Z" }, { "Status":"OFFLINE", "StatusChangedDate":"2017-11-02T13:24:00Z" }, { "Status":"ONLINE", "StatusChangedDate":"2017-11-02T14:35:00Z" }, { "Status":"OFFLINE", "StatusChangedDate":"2017-11-02T15:47:00Z" }..... ], "type":"User" } I need user's information along with his latest status details based on a particular date (or date range).

How are ids autogenerated in spring data couchbase?

冷暖自知 提交于 2019-12-11 06:58:38
问题 I want to create autogeneration of IDs to my documents in spring data couchbase. Spring docs has steps for this: https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.autokeygeneration Here is my code: @Document public class User { @Id @GeneratedValue(strategy = GenerationStrategy.USE_ATTRIBUTES, delimiter = ".") private String id; @IdPrefix(order=0) private String userPrefix; @IdSuffix(order=0) private String userSuffix; ... } I've a repository created for this:

Spring Data Couchbase Couldn't find PersistentEntity for type java.math.BigDecimal

ε祈祈猫儿з 提交于 2019-12-11 06:35:29
问题 I've hit the similar problem as described here: MappingInstantiationException with a BigInteger field in Spring Data Couchbase , so I've tried to workaround the problem with solution suggested by @Simon Baslé. I've added following custom converters: @Configuration @EnableCouchbaseRepositories @EnableCouchbaseAuditing public class CouchbaseConfig extends AbstractCouchbaseConfiguration { (...) @Override public CouchbaseCustomConversions customConversions() { return new

In Couchbase Java Query DSL, how do I filter for property-names that are not from the ASCII alphabet?

倖福魔咒の 提交于 2019-12-11 05:38:38
问题 Couchbase queries should support any String for property-name in a filter ( where clause.) But the query below returns no values for any of the fieldNames "7", "a", "#", "&", "", "?" . It does work for values for fieldName a . Note that I'm using the Java DSL API, not N1ql directly. OffsetPath statement = select("*").from(i(bucket.name())).where(x(fieldName).eq(x("$t"))); JsonObject placeholderValues = JsonObject.create().put("t", fieldVal); N1qlQuery q = N1qlQuery.parameterized(statement,

Couchbase: Connection refused

烂漫一生 提交于 2019-12-11 04:06:21
问题 I try to connect to a Couchbase server on the intranet. For this purpose, I use the Java SDK and the following configuration: CouchbaseEnvironment couchbaseEnvironment = DefaultCouchbaseEnvironment.builder() .queryEnabled(true) .queryPort(11210) .build(); Cluster cluster = CouchbaseCluster.create(couchbaseEnvironment, "192.168.1.150"); Bucket bucket = cluster.openBucket("mybucket"); However, this just leaves me with lots of errors on the console: INFO [2015-03-30 14:03:07,306] org.eclipse