I there, I noticed an issue with parametrized query using Java Client 2.3.7
which is by default included by Spring Data Couchabse.
Consider bucker activity which has a property data
containing an object.
Over the data property is created an index
CREATE INDEX `data-index` ON `activity` (DISTINCT ARRAY t FOR t WITHIN data END);
if I run following query via Administration panel
`SELECT count(*) as size FROM activity a WHERE ANY t WITHIN `data` SATISFIES t LIKE 'searchTerm' END`
everything works fine Execution: 7.45ms. In the buckets is 1.8M documents.
If the query is executed using Java Client
JsonObject params = JsonObject.create().put("query", 'searchTerm');
String statement = "SELECT count(*) as size FROM activity a WHERE ANY t WITHIN `data` SATISFIES t LIKE $query END";
N1qlQuery countN1ql = N1qlQuery.parameterized(statement, params);
N1qlQueryResult result = template.queryN1QL(countN1ql);
It is timing out. I think there is an issue with parametrized query, because if is in the statement directly used the searchTerm
like this:
String statement = "SELECT count(*) as size FROM activity a WHERE ANY t WITHIN `data` SATISFIES t LIKE 'searchTerm' END";
it works fine. But I don’t want directly put the search term in the query due to injection.
NOTE: The other parametrized statements works fine, just SATISFIES
cause somehow does not like it.
Thanks for help