n1ql

Couchbase parameterized N1QL query IN statement

元气小坏坏 提交于 2020-01-24 20:05:34
问题 Using com.couchbase.client, java-client version 2.2.7 I have been unable to get a n1ql query working that uses an IN statement with multiple items see my example query and java code below public int getCountForDuration(Long startTime, Long endTime, String ids){ JsonObject placeHolders = JsonObject.create().put("ids", ids).put("startTime", startTime).put("endTime", endTime); N1qlQuery query = N1qlQuery.parameterized(COUNT_STATEMENT, placeHolders) N1qlQueryResult result = bucket.query(query); .

Couchbase N1QL array query

前提是你 提交于 2020-01-13 06:58:08
问题 Document sample from my giata_properties bucket: link Relevant json paste { "propertyCodes": { "provider": [ { "code": [ { "value": [ { "value": "304387" } ] } ], "providerCode": "hotelbeds", "providerType": "gds" }, { "code": [ { "value": [ { "name": "Country Code", "value": "EG" }, { "name": "City Code", "value": "HRG" }, { "name": "Hotel Code", "value": "91U" } ] } ], "providerCode": "gta", "providerType": "gds" } ] }, "name": "Arabia Azur Resort" } I want a query (and an index) to

need to create Index for N1QL query

随声附和 提交于 2020-01-07 03:08:12
问题 I have below query select ROUND(sum(ARRAY_SUM(DailyCampaignUsage.`statistics`[*].clicksCost)),2) total_revenue, ROUND(sum(CASE WHEN DailyCampaignUsage.day between '2016-12-01' and '2016-12-23' THEN ARRAY_SUM(DailyCampaignUsage.`statistics`[*].clicksCost) ELSE 0 END),2) period_revenue, ROUND(sum(CASe WHEN DailyCampaignUsage.day between '2016-11-01' and '2016-11-23' THEN ARRAY_SUM(DailyCampaignUsage.`statistics`[*].clicksCost) ELSE 0 END),2) period_prev_revenue from Inheritx DailyCampaignUsage

Couchbase 4 beta “ORDER BY” performance

无人久伴 提交于 2020-01-06 01:30:16
问题 I have one question about performance of "ORDER BY" in Couchbase 4 Beta (Ubuntu 64bits). I create a Bucket "testing" and a primary index: CREATE PRIMARY INDEX `testing-idx` ON `testing` USING GSI; And a second index: CREATE INDEX testing_field_value_idx ON `testing`(field_value) USING GSI In my bucket I have items such as: { "type": "entry", "field_name": "field-testing", "field_value": "1 bla bla bla bla bla bla bla bla" }, { "type": "entry", "field_name": "field-testing", "field_value": "2

Twisted API for Couchbase not working with Python Tornado

不羁岁月 提交于 2020-01-03 20:11:09
问题 I'm trying to run a Tornado server with Couchbase 4.0 Developer preview. import tornado.web import tornado.httpserver import tornado.options import tornado.ioloop import tornado.websocket import tornado.httpclient from tornado import gen import os.path from tornado.options import define, options, parse_command_line import time #from couchbase.bucket import Bucket from twisted.internet import reactor from txcouchbase.bucket import Bucket from couchbase.n1ql import N1QLQuery, N1QLError from

want to sum inner element with JSON in using N1QLCouchbase

我是研究僧i 提交于 2019-12-31 05:36:54
问题 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 }

Index not improve speed in couchbase 4.5

冷暖自知 提交于 2019-12-25 07:48:16
问题 I have below query SELECT day,count(DISTINCT campaignId) campaigns FROM Inheritx use index(daily_type_1) where _type='DailyCampaignUsage' group by day I have below index `CREATE INDEX `daily_type_1` ON `Inheritx` (`_type`,`day`,(distinct (`campaignId`))) WHERE (`_type` = "DailyCampaignUsage")` it is taking 3s and I habe 52k data whare _type= "DailyCampaignUsage" how I Can improve it's speed ? 回答1: Modify your index as follows. CREATE INDEX `daily_type_1` ON `Inheritx` (campaignId,`day`) WHERE

N1QL and Node on Couchbase

牧云@^-^@ 提交于 2019-12-25 03:19:22
问题 I am trying to use N1QL with Node.js SDK of Couchbase. Here is my code: var config = require('../../config/init'); var N1qlQuery = require('couchbase').N1qlQuery; var query = N1qlQuery.fromString("SELECT * FROM users"); var db = couchbaseService(); console.log('start'); db.query(query, function(err, result) { if (err) { console.log('inside err'); console.log(err); return; } console.log('No error in NIQL'); console.log(result.object); }); Here is the error: TypeError: Cannot read property

Using N1QL with document keys

佐手、 提交于 2019-12-24 16:12:04
问题 I'm fairly new to couchbase and have tried to find the answer to a particular query I'm trying to create with not much success so far. I've debated between using a view or N1QL for this particular case and settled with N1QL but haven't managed to get it to work so maybe a view is better after all. Basically I have the document key (Group_1) for the following document: Group_1 { "cbType": "group", "ID": 1, "Name": "Group Atlas 3", "StoreList": [ 2, 4, 6 ] } I also have 'store' documents, their

Using IN clause in couchbase N1Ql @query or use findAll(keys) from couchbase JPA

点点圈 提交于 2019-12-24 06:30:51
问题 I am using Spring couchbase JPA and trying to fetch documents by giving a list of keys. My repository structure looks something like public interface EmployeeRepo extends CouchbasePagingAndSortingRepository<Employee, String>, EmployeeCustomRepo { I have a list of employee ids to search for and fetch the corresponding document. I tried using the method from curdRepository public List<Employee> findAllById(List<String> empIds) { return employeeRepo.findAll(empIds); } But I get exception as::