Odd behaviour with large numbers in index

Hello,

There seems to be a strange behaviour when querying a compound index on a property that is a large number (actually a long ).

For example, if you create the following 3 documents :

 {
  "dateTicks": 636320336400000000,
  "userId": "55"
}
{
  "dateTicks": 636320337000000000,
  "userId": "55"
}
{
  "dateTicks": 636320337600000000,
  "userId": "55"
}

And then create the index :

`> CREATE INDEX myIndex ON default(dateTicks,userId ) WHERE ((dateTicks is not missing) and (userId is not missing) )

Then if you query :

select count(*)
from `default`
where dateTicks >= 636320336400000000 
 and dateTicks <= 636320337600000000
 and userId is not missing

You will get 2 results.

But if you query :

select count(*)
from `default`
where dateTicks >= 636320336400000000 
 and dateTicks <= 636320337600000000
 and userId = "55" 

You will get 3 results, wich is the correct result actually.

Can anybody please tell me, what did I do wrong ?

Thank you,
Bogdan

Which version of Couchbase Server? Can you try this with 4.5.1. Prior to 4.5.1, all numbers were represented as float64, which can lead to loss of precision for some large integers.

In 4.5.1, all integers between MININT64 + 1 and MAXINT64 are represented exactly as int64.

Hello,

I tried with with 4.5.0 and 4.5.1

The same behaviour.

Can you try the same query without the index. This is just for debugging. 4.5.1.

USE INDEX (`#primary`)