Trouble converting collections query to Java ParameterizedN1qlQuery

I’m having trouble converting this N1QL query to be run in the Java SDK. Can someone help point out what I’m doing wrong?

This query works great in the Query Workbench Developer. I get back 1 result:

SELECT * FROM ledo b WHERE type="questionnaire/path"
AND META(b).id LIKE "questionnaire/path/2016/%"
AND ANY group1 WITHIN questionGroups SATISFIES ( = “VehExp.6so”) END

When I run this from the Java SDK, I get results with the following code:

Statement stmt = select("*")
.and(anyIn(“questionGroups”, x(“group1”)).satisfies(x(“”))));
JsonObject params = JsonObject.create()
.put(“keyPrefix”, “questionnaire/path/” + taxYear + “/%”)
.put(“type”, QuestionnairePath.DOCUMENT_TYPE)
.put(“id”, id);
ParameterizedN1qlQuery query = N1qlQuery.parameterized(stmt, params,

But when I try to add the equals statement, I don’t get any results:

.and(anyIn(“group1”, x(“questionGroups”)).satisfies(i(“”).eq(x("$id")))));

Can someone spot my bug in translating the query to code?

Hi @hoppe,

You can use toString on Statement/ParameterizedQuery and check if your query is constructed as expected. One thing I could spot is the last part of the where clause

and(anyWithin(“group1”, x(“questionGroups”)).satisfies(x(“”).eq(x("$id")))))

this matches more with the intended query

Note: ParameterizedQuery toString is only available on recent versions 2.3.6 and greater