Most of the setters you can use on the Query
object accept Booleans or Enums. Some of them accept strings as
well, which means the value given would be encoded and sent over
the wire. The problem is that Couchbase Server expects valid
JSON strings for some of them, which means you need to take care
of proper JSON handling yourself. To make your life easier, all
of these commands are overloaded and accept instances of the
ComplexKey class in addition to plain
Strings. These ComplexKey instances accept
any kind of Java objects and handle the proper JSON translation
for you.
To create ComplexKeys, you can use the
of() factory method like this as it accepts a
variable amount of java objects and/or types:
Query query = new Query(); // Generates valid ["Hello","World",5.12] JSON on the wire. ComplexKey rangeStart = ComplexKey.of("Hello", "World", 5.12); // Pass it in like this query.setRangeStart(rangeStart);
For more information about using views for indexing and querying from Couchbase Server, here are some useful resources:
General Information: Couchbase Server Manual: Views and Indexes.
Sample Patterns: to see examples and patterns you can use for views, see Couchbase Views, Sample Patterns.
Timestamp Pattern: many developers frequently ask about extracting information based on date or time. To find out more, see Couchbase Views, Sample Patterns.