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
Modifier and Type Method Description ViewQuerydebug()Enabled debugging on view queries.ViewQuerydebug(boolean debug)ViewQuerydescending()Return the documents in descending by key order.ViewQuerydescending(boolean desc)ViewQuerydevelopment()ViewQuerydevelopment(boolean development)protected Stringencode(String source)Helper method to properly encode a string.ViewQueryendKey(boolean key)ViewQueryendKey(double key)ViewQueryendKey(int key)ViewQueryendKey(long key)ViewQueryendKey(JsonArray key)ViewQueryendKey(JsonObject key)ViewQueryendKey(String key)ViewQueryendKeyDocId(String id)booleanequals(Object o)static ViewQueryfrom(String design, String view)Creates an newViewQuery.StringgetDesign()StringgetKeys()StringgetView()ViewQuerygroup()Group the results using the reduce function to a group or single row.ViewQuerygroup(boolean group)ViewQuerygroupLevel(int grouplevel)Specify the group level to be used.inthashCode()ViewQueryincludeDocs()Proactively load the full document for the row returned.ViewQueryincludeDocs(boolean includeDocs)Proactively load the full document for the row returned.ViewQueryincludeDocs(boolean includeDocs, Class<? extends Document<?>> target)Proactively load the full document for the row returned.ViewQueryincludeDocs(Class<? extends Document<?>> target)Proactively load the full document for the row returned.ViewQueryincludeDocsOrdered()Proactively load the full document for the row returned, while strictly retaining view row order.ViewQueryincludeDocsOrdered(boolean includeDocs)Proactively load the full document for the row returned, while strictly retaining view row order.ViewQueryincludeDocsOrdered(boolean includeDocs, Class<? extends Document<?>> target)Proactively load the full document for the row returned, while strictly retaining view row order.ViewQueryincludeDocsOrdered(Class<? extends Document<?>> target)Proactively load the full document for the row returned, while strictly retaining view row order.Class<? extends Document<?>>includeDocsTarget()ViewQueryinclusiveEnd()Specifies whether the specified end key should be included in the result.ViewQueryinclusiveEnd(boolean inclusive)booleanisDevelopment()booleanisIncludeDocs()booleanisOrderRetained()ViewQuerykey(boolean key)ViewQuerykey(double key)ViewQuerykey(int key)ViewQuerykey(long key)ViewQuerykey(JsonArray key)ViewQuerykey(JsonObject key)ViewQuerykey(String key)ViewQuerykeys(JsonArray keys)ViewQuerylimit(int limit)Limit the number of the returned documents to the specified number.ViewQueryonError(OnError onError)Sets the response in the event of an error.ViewQueryreduce()ViewQueryreduce(boolean reduce)Explicitly enable/disable the reduce function on the query.ViewQueryskip(int skip)Skip this number of records before starting to return the results.ViewQuerystale(Stale stale)Allow the results from a stale view to be used.ViewQuerystartKey(boolean key)ViewQuerystartKey(double key)ViewQuerystartKey(int key)ViewQuerystartKey(long key)ViewQuerystartKey(JsonArray key)ViewQuerystartKey(JsonObject key)ViewQuerystartKey(String key)ViewQuerystartKeyDocId(String id)StringtoQueryString()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.StringtoString()A string representation of this ViewQuery, suitable for logging and other human consumption.
-
Method Details
-
from
Creates an newViewQuery.- Parameters:
design- the name of the design document.view- the name of the view.- Returns:
- a
ViewQueryDSL.
-
development
-
development
-
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
ViewQueryDSL.
-
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.- Parameters:
target- the custom document type target.- Returns:
- the
ViewQueryDSL.
-
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.- Parameters:
includeDocs- if it should be enabled or not.- Returns:
- the
ViewQueryDSL.
-
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.- Parameters:
includeDocs- if it should be enabled or not.target- the custom document type target.- Returns:
- the
ViewQueryDSL.
-
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
ViewQueryDSL.
-
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(Class))} if you want to enforce the row order).- Parameters:
target- the custom document type target.- Returns:
- the
ViewQueryDSL.
-
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
ViewQueryDSL.
-
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, 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
ViewQueryDSL.
-
reduce
Explicitly enable/disable the reduce function on the query.- Parameters:
reduce- if reduce should be enabled or not.- Returns:
- the
ViewQueryobject for proper chaining.
-
reduce
-
limit
Limit the number of the returned documents to the specified number.- Parameters:
limit- the number of documents to return.- Returns:
- the
ViewQueryobject for proper chaining.
-
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
ViewQueryobject for proper chaining.
-
group
-
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
ViewQueryobject for proper chaining.
-
inclusiveEnd
Specifies whether the specified end key should be included in the result.- Returns:
- the
ViewQueryobject for proper chaining.
-
inclusiveEnd
-
skip
Skip this number of records before starting to return the results.- Parameters:
skip- The number of records to skip.- Returns:
- the
ViewQueryobject for proper chaining.
-
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
ViewQueryobject for proper chaining.
-
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
ViewQueryobject for proper chaining.
-
debug
Enabled debugging on view queries.- Returns:
- the
ViewQueryobject for proper chaining.
-
debug
-
descending
Return the documents in descending by key order.- Returns:
- the
ViewQueryobject for proper chaining.
-
descending
-
key
-
key
-
key
-
key
-
key
-
key
-
key
-
keys
-
startKeyDocId
-
endKeyDocId
-
endKey
-
endKey
-
endKey
-
endKey
-
endKey
-
endKey
-
endKey
-
startKey
-
startKey
-
startKey
-
startKey
-
startKey
-
startKey
-
startKey
-
encode
Helper method to properly encode a string. This method can be overridden if a different encoding logic needs to be used. If so, note thatkeysis not encoded via this method, but by the core.- Parameters:
source- source string.- Returns:
- encoded target 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
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
-
getView
-
getKeys
- Returns:
- the String JSON representation of the
keysparameter.
-
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() -
includeDocsTarget
-
equals
-
hashCode
public int hashCode()
-