Class SearchOptions
-
Nested Class Summary
Nested classes/interfaces inherited from class com.couchbase.client.java.CommonOptions
CommonOptions.BuiltCommonOptions
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
collections
(String... collectionNames) Allows to limit the search query to a specific list of collection names.consistentWith
(MutationState consistentWith) Sets mutation tokens this query should be consistent with.disableScoring
(boolean disableScoring) If set to true, thee server will not perform any scoring on the hits.explain
(boolean explain) Activates or deactivates the explanation of each result hit in the response, according to the parameter.facets
(Map<String, SearchFacet> facets) Adds oneSearchFacet
to the query.Configures the list of fields for which the whole value should be included in the response.Configures the highlighting of matches in the response for all fields, using the server's default highlighting style.highlight
(HighlightStyle style, String... fields) Configures the highlighting of matches in the response.Configures the highlighting of matches in the response, for the specified fields and using the server's default highlighting style.includeLocations
(boolean includeLocations) If set to true, will include theSearchRow.locations()
.limit
(int limit) Add a limit to the query on the number of rows it can return.Allows providing custom JSON key/value pairs for advanced usage.scanConsistency
(SearchScanConsistency consistency) Sets the unparameterized consistency to consider for this FTS query.static SearchOptions
serializer
(JsonSerializer serializer) skip
(int skip) Set the number of rows to skip (eg.Configures the list of fields (including special fields) which are used for sorting purposes.Methods inherited from class com.couchbase.client.java.CommonOptions
clientContext, parentSpan, retryStrategy, self, timeout
-
Method Details
-
searchOptions
-
raw
Allows providing custom JSON key/value pairs for advanced usage.If possible, it is recommended to use other methods on this object to customize the search query. The "raw" method should only be used if no such setter can be found (i.e. if an undocumented property should be set or you are using an older client and a new server-configuration property has been added to the cluster).
Note that the value will be passed through a JSON encoder, so do not provide already encoded JSON as the value. The value must be one of the following types:
- String
- Integer
- Long
- Double
- Boolean
- BigInteger
- BigDecimal
- JsonObject
- JsonArray
- Map (with String keys, and values from this list)
- List (with element types from this list)
- Parameters:
key
- the parameter name (key of the JSON property) or empty.value
- the parameter value (value of the JSON property).- Returns:
- the same
SearchOptions
for chaining purposes.
-
limit
Add a limit to the query on the number of rows it can return.- Parameters:
limit
- the maximum number of rows to return.- Returns:
- this SearchQuery for chaining.
-
skip
Set the number of rows to skip (eg. for pagination).- Parameters:
skip
- the number of results to skip.- Returns:
- this SearchQuery for chaining.
-
explain
Activates or deactivates the explanation of each result hit in the response, according to the parameter.- Parameters:
explain
- should the response include an explanation of each hit (true) or not (false)?- Returns:
- this SearchQuery for chaining.
-
highlight
Configures the highlighting of matches in the response.This drives the inclusion of the
fragments
in eachhit
.Note that to be highlighted, the fields must be stored in the FTS index.
- Parameters:
style
- theHighlightStyle
to apply.fields
- the optional fields on which to highlight. If none, all fields where there is a match are highlighted.- Returns:
- this SearchQuery for chaining.
-
highlight
Configures the highlighting of matches in the response, for the specified fields and using the server's default highlighting style.This drives the inclusion of the
fragments
in eachhit
.Note that to be highlighted, the fields must be stored in the FTS index.
- Parameters:
fields
- the optional fields on which to highlight. If none, all fields where there is a match are highlighted.- Returns:
- this SearchQuery for chaining.
-
highlight
Configures the highlighting of matches in the response for all fields, using the server's default highlighting style.This drives the inclusion of the
fragments
in eachhit
.Note that to be highlighted, the fields must be stored in the FTS index.
- Returns:
- this SearchQuery for chaining.
-
fields
Configures the list of fields for which the whole value should be included in the response. If empty, no field values are included.This drives the inclusion of the fields in each
hit
.Note that to be highlighted, the fields must be stored in the FTS index.
- Parameters:
fields
- the fields to include.- Returns:
- this SearchQuery for chaining.
-
collections
Allows to limit the search query to a specific list of collection names.NOTE: this is only supported with server 7.0 and later.
- Parameters:
collectionNames
- the names of the collections this query should be limited to.- Returns:
- this SearchQuery for chaining.
-
scanConsistency
Sets the unparameterized consistency to consider for this FTS query. This replaces any consistency tuning previously set.- Parameters:
consistency
- the simple consistency to use.- Returns:
- this
SearchOptions
for chaining.
-
consistentWith
Sets mutation tokens this query should be consistent with.- Parameters:
consistentWith
- the mutation state to be consistent with.- Returns:
- this
SearchOptions
for chaining.
-
sort
Configures the list of fields (including special fields) which are used for sorting purposes. If empty, the default sorting (descending by score) is used by the server.The list of sort fields can include actual fields (like "firstname" but then they must be stored in the index, configured in the server side mapping). Fields provided first are considered first and in a "tie" case the next sort field is considered. So sorting by "firstname" and then "lastname" will first sort ascending by the firstname and if the names are equal then sort ascending by lastname. Special fields like "_id" and "_score" can also be used. If prefixed with "-" the sort order is set to descending.
If no sort is provided, it is equal to sort("-_score"), since the server will sort it by score in descending order.
- Parameters:
sort
- the fields that should take part in the sorting.- Returns:
- this SearchQuery for chaining.
-
facets
Adds oneSearchFacet
to the query.This is an additive operation (the given facets are added to any facet previously requested), but if an existing facet has the same name it will be replaced.
This drives the inclusion of the facets in the
SearchResult
.Note that to be faceted, a field's value must be stored in the FTS index.
- Parameters:
facets
- the facets to add to the query.
-
serializer
-
disableScoring
If set to true, thee server will not perform any scoring on the hits.- Parameters:
disableScoring
- if scoring should be disabled.- Returns:
- these
SearchOptions
for chaining purposes.
-
includeLocations
If set to true, will include theSearchRow.locations()
.- Parameters:
includeLocations
- set to true to include the locations.- Returns:
- these
SearchOptions
for chaining purposes.
-
build
-