I want to use the ff query for an endpoint I’m developing
SELECT RAW OBJECT_REMOVE(b, 'property1', 'property2') FROM mybucket b ...
I tried running it on the web UI and it works and fetches the right data but the same query passed to Cluster.query(...)
on Java SDK returns empty.
What could be possible reason/s for this? Also, can the SDK be instrumented so that I can inspect the actual query that gets sent to the server?
I’ll look at this later today. A common issue with web ui vs sdk is that an insert or update requires a small amount of time to index - such that a modification immediately followed by a select on the index will not have the new indexed data. While in the webui, enough time passes between executing the modification and executing the select. The solution for that is to use the query option query scan consistency = REQUEST_PLUS. Can you show all your code? The complete select statement and options (if any) and how the code determines if the result is empty. Is the result no rows? Or rows that are empty.
You can find the actual request in the server’s preparedds.json log. The SDK does not alter the query string provided to it.
I can’t reproduce the reported behavior…
{
"property1": 1,
"property2": 2,
"property3": 3
}
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.query.QueryResult;
public class SimpleQueryExample {
public static void main(String... args) {
Cluster cluster = Cluster.connect("127.0.0.1", "Administrator", "password");
QueryResult result = cluster.query(
"SELECT RAW OBJECT_REMOVE(b, 'property1', 'property2') FROM my_bucket b where meta().id='00'"
);
System.err.println(result.rowsAsObject());
}
}
[{"property3":3}]
Sorry for waste of time. I assumed wrongly. It was the deserialization library setting a field to null instead of omitting it and I assumed it was an “explicit null” instead of undefined null.
1 Like
No.problem, glad to help.