Use stored procedure for optimal prefix-based search.
For example, this snippet works with cyrillic texts too:
box.schema.create_space('address')
box.space.address:create_index('prefix', { type = 'tree', parts = { { 1, 'str', collation = 'unicode_ci' } }, unique = true })
select_by_prefix = function(prefix)
local result = {}
for _, addr in box.space.address.index.prefix:pairs(prefix, { iterator = 'GT' }) do
if utf.casecmp(utf.sub(addr[1], 1, utf.len(prefix)), prefix) == 0 then
table.insert(result, addr)
else
break
end
end
return result
end