Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library: Java 1.1
Community Wiki and Resources
Download Client Library
JavaDoc
Couchbase Developer Guide 2.0
Couchbase Server Manual 2.0
Java Client Library
SDK Forum
Wiki: Java Client Library
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
1.4 Advanced Topics
Chapter Sections
Chapters

1.4.3. View Queries with ComplexKeys

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: