Hi I am trying to implement a cmpRegex search with javascript. I have looked at the documentation and into the code and could not really figure out the way to do it.
I have managed to implement it in python here is the code:
import aerospike
import sys
from aerospike import exception as ex
from aerospike import predicates
from aerospike_helpers import expressions as exp
config = {'hosts': [('127.0.0.1', 3000)]}
client = aerospike.client(config).connect()
client.index_string_create('test', 'test1', 'name', 'test1_name_idx')
for i in range(1000):
key = ('test', 'test1', str(i))
rec = {
'name': 'test' + str(i),
'tags': ['test' + str(i), 'test' + str(i+1)]
}
client.put(key, rec)
def showRes(record):
print(record[2].get("name"))
query = client.query('test', 'test1')
q_regex = exp.CmpRegex(aerospike.REGEX_ICASE, "^test55.*.", exp.StrBin("name")).compile()
scan_policy={"expressions": q_regex}
records = query.results(scan_policy)
for r in records:
showRes(r)