RethinkDB 复合索引的怪异使用之间 [英] RethinkDB Compound Index Weirdness Using Between

查看:54
本文介绍了RethinkDB 复合索引的怪异使用之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 RethinkDB 中的 between 函数中的复合索引有些奇怪.它似乎检索与查询不匹配的结果.详情如下.

I've noticed something strange with compound indexes in the between function in RethinkDB. It seems to retrieve results that don't match the query. It's all detailed below.

r.dbCreate('test')

r.db('test').tableCreate('numbers')

r.db('test').table('numbers').insert([
    { first: 1, second: 1 },
    { first: 1, second: 2 },    
    { first: 1, second: 3 },    
    { first: 1, second: 4 },    
    { first: 1, second: 5 },    
    { first: 2, second: 1 },    
    { first: 2, second: 2 },    
    { first: 2, second: 3 },    
    { first: 2, second: 4 },    
    { first: 2, second: 5 },    
    { first: 3, second: 1 },    
    { first: 3, second: 2 },    
    { first: 3, second: 3 },    
    { first: 3, second: 4 },    
    { first: 3, second: 5 },
    { first: 4, second: 1 },    
    { first: 4, second: 2 },    
    { first: 4, second: 3 },    
    { first: 4, second: 4 },    
    { first: 4, second: 5 },    
    { first: 5, second: 1 },    
    { first: 5, second: 2 },    
    { first: 5, second: 3 },    
    { first: 5, second: 4 },    
    { first: 5, second: 5 }
  ])

r.db('test').table('numbers').indexCreate(
    "both", [r.row("first"), r.row("second")])

r.db('test').table('numbers').orderBy({index :'both'}).between(
  [2, 3], [3, 5], {index: 'both', rightBound: 'closed'}).without('id')

// output

{ "first": 3 , 
"second": 3 
} // ok

{ "first": 3 , 
"second": 4 
} // ok

{ "first": 2 , 
"second": 5 
} // ok

{ "first": 3 , 
"second": 1 
} // not ok

{ "first": 3 , 
"second": 5 
} // ok

{ "first": 3 , 
"second": 2 
} // not ok

{ "first": 2 , 
"second": 3 
} // ok

{ "first": 2 , 
"second": 4 
} // ok

查询中的数组似乎不像 AND 或 OR.是我遗漏了什么还是这是一个错误?

The array in the query doesn't appear to act like an AND or an OR. Am I missing something or is this a bug?

推荐答案

好的,感谢 originalexe 在 Slack 频道上的一些帮助,我已经解决了这个问题.它的行为正常,基本上数组被视为单个值,查询返回有序列表中介于两者之间的所有值.

Ok so thanks to some help from originalexe over on the Slack channel I've figured this out. It's behaving as normal and essentially the array is treated as a single value and the query returns all values that are between the two in an ordered list.

这篇关于RethinkDB 复合索引的怪异使用之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆