User Tools

Site Tools


Sidebar

indexes:tree_patterns

Q. How can I do value like 'pattern%s' with a TREE index? (2016)

A. Specify a partial key for the GE iterator:

for k, v in 
space:pairs('pattern', {iterator = 'GE'}) do if it_is_not_like(v) 
break <do stuff with v> end

You can also do it with pairs():

for tuple in
box.space.t.index.primary:pairs("XY",{iterator = "GE"}) do
  if (string.sub(tuple[1], 1, 2) ~= "XY") then break end
  print(tuple)
end

This Lua code finds all the tuples whose primary key values begin with ‘XY’. One of the assumptions is that there is a one-part primary-key TREE index on the first field, which must be a string. The iterator loop ensures that the search returns tuples where the first value is greater than or equal to ‘XY’. The conditional statement within the loop ensures that the looping stops when the first two letters are not ‘XY’.

Comments

Enter your comment. Wiki syntax is allowed:
P T A J V
 
indexes/tree_patterns.txt · Last modified: 2018/06/04 16:54 by eabates

Real Time Web Analytics