I want to write a query to find a list of strings which contains sub-strings, e.g
"xyz-1",
"xyz-2",
"xyz-3",
"xyz-4".....
Above is list of Strings i need to find but i have input as xyz only and not the fullname xyz-1.
In couchbase server i have implemented the query as below,
SELECT * FROM test
WHERE ANY v IN namelist SATISFIES v LIKE '%xyz%' END;
which will give me all the list name containing xyz. But implementing in Spring boot application its not working.
Below is my spring boot @query menthod
@Query("Select * from `test` where #{#n1ql.filter} And ANY v In namelist SATISFIES v Like '%$1'% END within #{#n1ql.bucket}")
List<String> findBynameList(String name);
and below is my pojo class ,
@Id
private String car_id;
@Field
@NotNull
private String name;
@Field
private List<String> namelist;
Right side of the LIKE must be string or query named/positional parameters of string.
If query named/positional parameters inside the string will not be replaced. You have '%$1'% , it will look for $1 not value.
If you want look for value write like this
v LIKE $1 ===> supply $1 as "%actualvalue%"
v LIKE "%" || $1 || "%"