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 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 Details
-
from
Creates an newViewQuery
.- Parameters:
design
- the name of the design document.view
- the name of the view.- Returns:
- a
ViewQuery
DSL.
-
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
ViewQuery
DSL.
-
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
ViewQuery
DSL.
-
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
ViewQuery
DSL.
-
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
ViewQuery
DSL.
-
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
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
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
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
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
-
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
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
-
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
Specifies whether the specified end key should be included in the result.- Returns:
- the
ViewQuery
object 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
ViewQuery
object 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
ViewQuery
object 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
ViewQuery
object for proper chaining.
-
debug
Enabled debugging on view queries.- Returns:
- the
ViewQuery
object for proper chaining.
-
debug
-
descending
Return the documents in descending by key order.- Returns:
- the
ViewQuery
object 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 thatkeys
is 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
keys
parameter.
-
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()
-