Package com.couchbase.client.java.view
Class ViewQuery
- java.lang.Object
-
- com.couchbase.client.java.view.ViewQuery
-
- All Implemented Interfaces:
Serializable
public class ViewQuery extends Object implements Serializable
Fluent DSL for a View Query.- Since:
- 2.0.0
- Author:
- Michael Nitschinger
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ViewQuery
debug()
Enabled debugging on view queries.ViewQuery
debug(boolean debug)
ViewQuery
descending()
Return the documents in descending by key order.ViewQuery
descending(boolean desc)
ViewQuery
development()
ViewQuery
development(boolean development)
protected String
encode(String source)
Helper method to properly encode a string.ViewQuery
endKey(boolean key)
ViewQuery
endKey(double key)
ViewQuery
endKey(int key)
ViewQuery
endKey(long key)
ViewQuery
endKey(JsonArray key)
ViewQuery
endKey(JsonObject key)
ViewQuery
endKey(String key)
ViewQuery
endKeyDocId(String id)
boolean
equals(Object o)
static ViewQuery
from(String design, String view)
Creates an newViewQuery
.String
getDesign()
String
getKeys()
String
getView()
ViewQuery
group()
Group the results using the reduce function to a group or single row.ViewQuery
group(boolean group)
ViewQuery
groupLevel(int grouplevel)
Specify the group level to be used.int
hashCode()
ViewQuery
includeDocs()
Proactively load the full document for the row returned.ViewQuery
includeDocs(boolean includeDocs)
Proactively load the full document for the row returned.ViewQuery
includeDocs(boolean includeDocs, Class<? extends Document<?>> target)
Proactively load the full document for the row returned.ViewQuery
includeDocs(Class<? extends Document<?>> target)
Proactively load the full document for the row returned.ViewQuery
includeDocsOrdered()
Proactively load the full document for the row returned, while strictly retaining view row order.ViewQuery
includeDocsOrdered(boolean includeDocs)
Proactively load the full document for the row returned, while strictly retaining view row order.ViewQuery
includeDocsOrdered(boolean includeDocs, Class<? extends Document<?>> target)
Proactively load the full document for the row returned, while strictly retaining view row order.ViewQuery
includeDocsOrdered(Class<? extends Document<?>> target)
Proactively load the full document for the row returned, while strictly retaining view row order.Class<? extends Document<?>>
includeDocsTarget()
ViewQuery
inclusiveEnd()
Specifies whether the specified end key should be included in the result.ViewQuery
inclusiveEnd(boolean inclusive)
boolean
isDevelopment()
boolean
isIncludeDocs()
boolean
isOrderRetained()
ViewQuery
key(boolean key)
ViewQuery
key(double key)
ViewQuery
key(int key)
ViewQuery
key(long key)
ViewQuery
key(JsonArray key)
ViewQuery
key(JsonObject key)
ViewQuery
key(String key)
ViewQuery
keys(JsonArray keys)
ViewQuery
limit(int limit)
Limit the number of the returned documents to the specified number.ViewQuery
onError(OnError onError)
Sets the response in the event of an error.ViewQuery
reduce()
ViewQuery
reduce(boolean reduce)
Explicitly enable/disable the reduce function on the query.ViewQuery
skip(int skip)
Skip this number of records before starting to return the results.ViewQuery
stale(Stale stale)
Allow the results from a stale view to be used.ViewQuery
startKey(boolean key)
ViewQuery
startKey(double key)
ViewQuery
startKey(int key)
ViewQuery
startKey(long key)
ViewQuery
startKey(JsonArray key)
ViewQuery
startKey(JsonObject key)
ViewQuery
startKey(String key)
ViewQuery
startKeyDocId(String id)
String
toQueryString()
Returns the query string for this ViewQuery, containing all the key/value pairs for parameters that will be part of this ViewQuery's execution URL for the view service.String
toString()
A string representation of this ViewQuery, suitable for logging and other human consumption.
-
-
-
Method Detail
-
from
public static ViewQuery from(String design, String view)
Creates an newViewQuery
.- Parameters:
design
- the name of the design document.view
- the name of the view.- Returns:
- a
ViewQuery
DSL.
-
development
public ViewQuery development()
-
development
public ViewQuery development(boolean development)
-
includeDocsOrdered
public ViewQuery includeDocsOrdered()
Proactively load the full document for the row returned, while strictly retaining view row order. This only works if reduce is false, since with reduce the original document ID is not included anymore.- Returns:
- the
ViewQuery
DSL.
-
includeDocsOrdered
public ViewQuery includeDocsOrdered(Class<? extends Document<?>> target)
Proactively load the full document for the row returned, while strictly retaining view row order. This only works if reduce is false, since with reduce the original document ID is not included anymore.- Parameters:
target
- the custom document type target.- Returns:
- the
ViewQuery
DSL.
-
includeDocsOrdered
public ViewQuery includeDocsOrdered(boolean includeDocs)
Proactively load the full document for the row returned, while strictly retaining view row order. This only works if reduce is false, since with reduce the original document ID is not included anymore.- Parameters:
includeDocs
- if it should be enabled or not.- Returns:
- the
ViewQuery
DSL.
-
includeDocsOrdered
public ViewQuery includeDocsOrdered(boolean includeDocs, Class<? extends Document<?>> target)
Proactively load the full document for the row returned, while strictly retaining view row order. This only works if reduce is false, since with reduce the original document ID is not included anymore.- Parameters:
includeDocs
- if it should be enabled or not.target
- the custom document type target.- Returns:
- the
ViewQuery
DSL.
-
includeDocs
public ViewQuery includeDocs()
Proactively load the full document for the row returned. This only works if reduce is false, since with reduce the original document ID is not included anymore. The order could be changed if one of the document takes longer to load than the others (seeincludeDocsOrdered()
)} if you want to enforce the row order).- Returns:
- the
ViewQuery
DSL.
-
includeDocs
public ViewQuery includeDocs(Class<? extends Document<?>> target)
Proactively load the full document for the row returned. This only works if reduce is false, since with reduce the original document ID is not included anymore. The order could be changed if one of the document takes longer to load than the others (seeincludeDocsOrdered(Class)
)} if you want to enforce the row order).- Parameters:
target
- the custom document type target.- Returns:
- the
ViewQuery
DSL.
-
includeDocs
public ViewQuery includeDocs(boolean includeDocs)
Proactively load the full document for the row returned. This only works if reduce is false, since with reduce the original document ID is not included anymore. The order could be changed if one of the document takes longer to load than the others (seeincludeDocsOrdered(boolean)
if you want to enforce the row order).- Parameters:
includeDocs
- if it should be enabled or not.- Returns:
- the
ViewQuery
DSL.
-
includeDocs
public ViewQuery includeDocs(boolean includeDocs, Class<? extends Document<?>> target)
Proactively load the full document for the row returned. This only works if reduce is false, since with reduce the original document ID is not included anymore. The order could be changed if one of the document takes longer to load than the others (seeincludeDocsOrdered(boolean, Class)
if you want to enforce the row order).- Parameters:
includeDocs
- if it should be enabled or not.target
- the custom document type target.- Returns:
- the
ViewQuery
DSL.
-
reduce
public ViewQuery reduce(boolean reduce)
Explicitly enable/disable the reduce function on the query.- Parameters:
reduce
- if reduce should be enabled or not.- Returns:
- the
ViewQuery
object for proper chaining.
-
reduce
public ViewQuery reduce()
-
limit
public ViewQuery limit(int limit)
Limit the number of the returned documents to the specified number.- Parameters:
limit
- the number of documents to return.- Returns:
- the
ViewQuery
object for proper chaining.
-
group
public ViewQuery group()
Group the results using the reduce function to a group or single row. Important: this setter andgroupLevel(int)
should not be used together in the sameViewQuery
. It is sufficient to only set the grouping level only and use this setter in cases where you always want the highest group level implictly.- Returns:
- the
ViewQuery
object for proper chaining.
-
group
public ViewQuery group(boolean group)
-
groupLevel
public ViewQuery groupLevel(int grouplevel)
Specify the group level to be used. Important:group()
and this setter should not be used together in the sameViewQuery
. It is sufficient to only use this setter and usegroup()
in cases where you always want the highest group level implictly.- Parameters:
grouplevel
- How deep the grouping level should be.- Returns:
- the
ViewQuery
object for proper chaining.
-
inclusiveEnd
public ViewQuery inclusiveEnd()
Specifies whether the specified end key should be included in the result.- Returns:
- the
ViewQuery
object for proper chaining.
-
inclusiveEnd
public ViewQuery inclusiveEnd(boolean inclusive)
-
skip
public ViewQuery skip(int skip)
Skip this number of records before starting to return the results.- Parameters:
skip
- The number of records to skip.- Returns:
- the
ViewQuery
object for proper chaining.
-
stale
public ViewQuery stale(Stale stale)
Allow the results from a stale view to be used. See the "Stale" enum for more information on the possible options. The default setting is "update_after"!- Parameters:
stale
- Which stale mode should be used.- Returns:
- the
ViewQuery
object for proper chaining.
-
onError
public ViewQuery onError(OnError onError)
Sets the response in the event of an error. See the "OnError" enum for more details on the available options.- Parameters:
onError
- The appropriate error handling type.- Returns:
- the
ViewQuery
object for proper chaining.
-
debug
public ViewQuery debug()
Enabled debugging on view queries.- Returns:
- the
ViewQuery
object for proper chaining.
-
debug
public ViewQuery debug(boolean debug)
-
descending
public ViewQuery descending()
Return the documents in descending by key order.- Returns:
- the
ViewQuery
object for proper chaining.
-
descending
public ViewQuery descending(boolean desc)
-
key
public ViewQuery key(int key)
-
key
public ViewQuery key(long key)
-
key
public ViewQuery key(double key)
-
key
public ViewQuery key(boolean key)
-
key
public ViewQuery key(JsonObject key)
-
endKey
public ViewQuery endKey(int key)
-
endKey
public ViewQuery endKey(long key)
-
endKey
public ViewQuery endKey(double key)
-
endKey
public ViewQuery endKey(boolean key)
-
endKey
public ViewQuery endKey(JsonObject key)
-
startKey
public ViewQuery startKey(int key)
-
startKey
public ViewQuery startKey(long key)
-
startKey
public ViewQuery startKey(double key)
-
startKey
public ViewQuery startKey(boolean key)
-
startKey
public ViewQuery startKey(JsonObject key)
-
encode
protected String encode(String source)
Helper method to properly encode a string. This method can be overridden if a different encoding logic needs to be used. If so, note thatkeys
is not encoded via this method, but by the core.- Parameters:
source
- source string.- Returns:
- encoded target string.
-
toQueryString
public String toQueryString()
Returns the query string for this ViewQuery, containing all the key/value pairs for parameters that will be part of this ViewQuery's execution URL for the view service.
-
toString
public String toString()
A string representation of this ViewQuery, suitable for logging and other human consumption. If thekeys(JsonArray)
parameter is too large, it is truncated in this dump. see thetoQueryString()
for the parameter representation of the ViewQuery execution URL.
-
getDesign
public String getDesign()
-
getView
public String getView()
-
isOrderRetained
public boolean isOrderRetained()
- Returns:
- true if row order, as returned by the view, should be kept while also
including docs
.
-
isDevelopment
public boolean isDevelopment()
-
isIncludeDocs
public boolean isIncludeDocs()
-
-