问题
My case is very simple. I need to do a contains/like search over a field. Based on this documentation you can do a regex to achieve this:
items/item[name =~ ".*{value}.*"; skip pagination.startOn; limit pagination.numberOf; order +modifiedOn]
But I'm getting a compilation error at the =~
operator. Checking the output of the compilation error I saw that this are the options that I've
Hint: expected "!=" or "<" or "<=" or "==" or ">" or ">=" or "[" or "as" or "_" or "else" or "then" or "if" or "do" or "type" or "with" or "match" or "exists" or "in" or ' ' or ' ' or <spacing>
Which of those options will allow me to do the regex query?
I'm using this version of opa (I'm stuck with it for the moment)
OPA version 0.9.2
(c) 2007-2012 MLstate, All Rights Reserved.
Build: 1815-(fe5cc09)
回答1:
Regular expression support is quite new addition to the Opa, and you have outdated compiler. Note, that Mongo $regex operator may impact performance significantly because of how it uses indexes. See the discussion on text search in Opa.
来源:https://stackoverflow.com/questions/30855810/how-to-do-like-queries-in-opa