Hi community
We are migrating from our old aerospike version 3.15.1.4 to version 6.2.0.7. This involves the migration from aerospike-client-go v4.5.2+incompatible to aerospike-client-go/v6 v6.6.0. Predicate Expressions (PredExp) have been deprecated since Aerospike Database 5.2. They were removed in Aerospike Database 6.0. So we have to move to Aerospike Expressions.
We have a bin with a string-list in it. And we want to do a search with a “begins-with” pattern. In the old world, we do that with following code:
as.NewPredExpStringVar("v"),
as.NewPredExpStringValue("^"+regexp.QuoteMeta("search_term")),
as.NewPredExpStringRegex(QueryRegexOptionExtended|QueryRegexOptionIgnoreCase),
as.NewPredExpListBin("ListField"),
as.NewPredExpListIterateOr("v"),
Following examples will search vor exact value:
// As filter inside statement
as.NewContainsFilter("ListField", as.ICT_LIST, "search_term")
// As FilterExpression on query-policy
*as.ExpGreater(
as.ExpListGetByValue(
as.ListReturnTypeCount,
as.ExpStringVal("search_term"),
as.ExpListBin("ListField")),
as.ExpIntVal(0),
But how can we achive a “begins-with-search” with the new Aerospike Expressions?
++++
For more background-info, this is the db-setup:
We have following model which is getting stored inside aerospike:
type MyModel struct {
ListField []string
[some-other-fields]
}
And following secondary index: Index name: idx_MYSET_ListField / namespace: myns / set: MYSET / bin: ListField / bin: string / index: list / State: RW
And if I read a sample record over aql:
aql> select PK,ListField from myns.MYSET where PK = 12345
+--------------------+-----------------------------------------+
| PK | ListField |
+--------------------+-----------------------------------------+
| 12345 | LIST('["myid:1234", "testid2", "some-other-value"]') |
+--------------------+-----------------------------------------+