Tarantool分片 - 如何通过二级索引进行搜索?

时间:2017-11-08 19:23:13

标签: caching nosql sharding tarantool

对于tarantool上的分片,我正在使用岩石https://github.com/tarantool/shard,它非常适合按primary索引进行搜索。

我的空格events带有primary密钥和secondary索引。

box.schema.create_space('events')
box.space.events:create_index(
    "id", {type = 'primary', parts = {1, 'unsigned'}}
)
box.space.events:create_index(
    "secondary", {type = "tree", unique=true, parts = {2, 'str'}}
)
shard.events:insert{1, "pv.1", 3, 12345671, "uuid1"}
shard.events:insert{2, "pv.2", 3, 12345672, "uuid2"}

-- query by primary index works! and return tuple
shard.events:select{2} 

-- query by secondary index NOT work!
shard.events.index.event_hash:select('pv.2', {iterator = box.index.EQ}) 

我的问题是:

通过secondary索引我必须使用什么或者我必须为查询分片做些什么?

0 个答案:

没有答案