N1ql error on node.js

Hi,

Running a query on the web console is OK.
But running the same query via node.js I get this error after few seconds:
{ Error: An unknown N1QL error occured. This is usually related to an out-of-memory condition. Check the errors responseBody property or inspect the cluster logs for further details. at /Users/Development/couchbase_test/node_modules/couchbase/lib/bucket.js:945:17 responseBody: '' }

it is not a memory issue - there is plenty available…

UPDATE:

tested on two different machines (couchbase-Enterprise-server) - same result.

@El_Ts I am sorry you are running into problems. Can you please share the query that you are running and details around Operating system, Couchbase Server version? We can figure out the next steps

Hi @raju ,
I’m using CB Server 6.0 Ent.

The query:

SELECT t1.datetime , t1.data.speed as speed, avg(t2.data.speed) as avg
FROM Winds t1 join Winds t2
ON t2.datetime between DATE_ADD_STR( t1.datetime ,-5, 'day') and t1.datetime
WHERE t1.type="wind speed" and t2.type='wind speed' 
and t2.data.speedIS NOT NULL
group by t1.datetime,t1.data.speed

also this query is VERY slow. take about 6 minutes while on other DBs’ few seconds…
And I tried several indexes but the best one was:

CREATE INDEX `winds_index` ON `Winds`(`type`,`datetime`,`data.speed`)
CREATE INDEX `winds_index` ON `Winds`(`datetime`, data.speed) WHERE type = "wind speed";

SELECT t1.datetime, t1.data.speed AS speed, AVG(t2.data.speed) AS avg
FROM Winds t1
JOIN Winds t2 ON t2.datetime BETWEEN DATE_ADD_STR(t1.datetime ,-5, 'day') AND t1.datetime
WHERE t1.type = "wind speed"
      AND t1.datetime IS NOT NULL
      AND t1.data.speed IS NOT NULL
      AND t2.type = "wind speed"
GROUP BY t1.datetime, t1.data.speed;

It looks like you are doing moving average of last 5 days using self join. This makes easier and faster in the next release with window functions. cc @keshav_m, @binh.le

https://blog.couchbase.com/json-to-insights-fast-and-easy/
https://blog.couchbase.com/on-par-with-window-functions-in-n1ql/