n1ql

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"

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).

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,

In Couchbase Java Query DSL, how do I filter for field-values that are not ASCII?

馋奶兔 提交于 2019-12-11 03:33:15
问题 Using Couchbase Java DSL, a query using "fish/piraña" gives a parse-error, but with "fish/piranha" , there is no parse-error. I had thought that the x() method would correctly wrap the non-ASCII Unicode string. Using N1ql directly, this does work with any field name (except blank) or field value: parameterized("SELECT * from " + bucket.name() + " WHERE " + fieldName + " = $v", placeholders)) How can this be done using the Java Query DSL? String species "fish/pira\u00f1a" ; Expression

How to rename a bucket in couchbase?

核能气质少年 提交于 2019-12-10 19:19:03
问题 I have a bucket name 0001 when I use the following N1QL statement I get a "5000" syntax error: cbq> Select * from 0001; { "requestID": "f2b70856-f80c-4c89-ab37-740e82d119b5", "errors": [ { "code": 5000, "msg": "syntax error" } ], "status": "fatal", "metrics": { "elapsedTime": "349.733us", "executionTime": "204.442us", "resultCount": 0, "resultSize": 0, "errorCount": 1 } } I think it takes 0001 as a number and not as a bucket name, is there an easy way to rename it? 回答1: In this case you can

n1ql query to remove data from array which has parameter value null

纵然是瞬间 提交于 2019-12-10 11:04:02
问题 Following is the sample document (userdetails) in couchbase. { "friends":[ { "company":"microsoft", "firstname":"criss", "lastname":"angel" }, { "company":"google", "firstname":"captain", "lastname":null } ] } based on the company name, i want to remove the respective json document from the array. n1ql query update default use keys "userdetails" set friends=array_remove(friends,a) for a in friends when a.company="google" end returning friends Im not able to remove the json data using the

N1QL Query times out when Using parameterized IN clause

拥有回忆 提交于 2019-12-06 22:40:21
问题 Using Couchbase server 4.1.0 (and 4.5), Java SDK 2.2.8 (also tried with 2.2.7, 2.3.1, & 2.3.3), I have a query leveraging a secondary index which runs fine when I run my code locally and even via CBQ (CBQ takes about 3ms) on the AWS server. However, when running my app on AWS, I get a TimeOutException and it's only one query which is timing out, others are not. See details below. May be worth noting my Couchbase setup has 3 buckets. Example Doc: "bucketName": { "userName": "User_A",

N1QL Query times out when Using parameterized IN clause

狂风中的少年 提交于 2019-12-05 02:59:06
Using Couchbase server 4.1.0 (and 4.5), Java SDK 2.2.8 (also tried with 2.2.7, 2.3.1, & 2.3.3), I have a query leveraging a secondary index which runs fine when I run my code locally and even via CBQ (CBQ takes about 3ms) on the AWS server. However, when running my app on AWS, I get a TimeOutException and it's only one query which is timing out, others are not. See details below. May be worth noting my Couchbase setup has 3 buckets. Example Doc: "bucketName": { "userName": "User_A", "MessageContent": "This is a message", "docType": "msg", "ParentMsgId": "1234", "MsgType": "test",

want to sum inner element with JSON in using N1QLCouchbase

故事扮演 提交于 2019-12-02 09:57:49
when I run below query SELECT * FROM myBucket WHERE ANY x IN transactions SATISFIES x.type in [0,4] END; Result: { "_type": "Company", "created": "2015-12-01T18:30:00.000Z", "transactions": [ { "amount": "96.5", "date": "2016-01-03T18:30:00.000Z", "type": 0 }, { "amount": "483.7", "date": "2016-01-10T18:30:00.000Z", "type": 0 } ] } I get multiple json like this SELECT sum(transactions[*].amount) FROM Inheritx WHERE ANY x IN transactions SATISFIES x.type in [0,4] END; Result: [ { "$1": null } ] Now I want to sum of all this. How can I do it? transactions[*].amount this is return array so first

How to fetch a field from document using n1ql with spring-data-couchbase

丶灬走出姿态 提交于 2019-12-02 07:27:21
This is the query in the repository which works fine. public interface PlayerRepo extends CrudRepository<Player, String>{ @Query("#{#n1ql.selectEntity} WHERE code = $1 and #{#n1ql.filter}") public List<Player> findPlayersWithCode(String code); } I want to fetch specific field from Player document, like this: @Query("#{#n1ql.selectEntity.name} WHERE code = $1 and #{#n1ql.filter}") public List<String> findPlayerNamesWithCode(String code); Is it possible to do this, I am using spring-data-couchbase 2.1.2 Currently, this is not possible from a repository. Spring Data Hopper introduced a Projection