Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 如何通过Tarantool中的二级索引进行选择?_Lua_Tarantool - Fatal编程技术网

Lua 如何通过Tarantool中的二级索引进行选择?

Lua 如何通过Tarantool中的二级索引进行选择?,lua,tarantool,Lua,Tarantool,我创建了一个包含两个索引的空间—主索引和辅助索引: box.schema.sequence.create('user_seq',{if_not_exists=true}) box.schema.space.create('user'{ 如果_not_exists=true, 格式={ {name='id',type='unsigned'}, {name='bio',type='string'} } }) box.space.user:创建\u index('id'{ 顺序='用户顺序', par

我创建了一个包含两个索引的空间—主索引和辅助索引:

box.schema.sequence.create('user_seq',{if_not_exists=true})
box.schema.space.create('user'{
如果_not_exists=true,
格式={
{name='id',type='unsigned'},
{name='bio',type='string'}
}
})
box.space.user:创建\u index('id'{
顺序='用户顺序',
parts={'id'}
})
box.space.user:创建索引('bio'{
parts={'bio'},
如果_not_exists=true,
唯一=错误
})
插入元组:

tarantool>box.space.user:insert({box.sequence.user_seq:next(),'other stuff'})
---
-[1,‘其他东西’]
...
我尝试过这样搜索:

box.space.user:选择({'other stuff'})
并得到了错误信息:

-错误:“提供的部分0的键类型与索引部分类型不匹配:应为未签名”

如何通过二级索引进行搜索?

文档中说:

index.index-name是可选的。如果省略,则假定索引是第一个(主键)索引。因此,对于上面的示例,box.space.tester:select({1},{iterator='GT'})将通过'primary'索引返回相同的两行

明确使用该辅助索引:

tarantool>box.space.user.index.bio:select({'other stuff'})
---
--[1,‘其他东西’]
...
阅读更多关于它的信息