K - the key typepublic static class SearchArgs.Builder<K> extends Object
SearchArgs.
As a final step the build() method needs to be executed to create the final SearchArgs
instance.
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
SearchArgs<K> |
build()
Build a new instance of the
SearchArgs. |
SearchArgs.Builder<K> |
dialect(QueryDialects dialect)
Set the query dialect.
|
SearchArgs.Builder<K> |
expander(String expander)
Use a custom query expander instead of the stemmer
|
SearchArgs.Builder<K> |
highlightArgs(HighlightArgs highlightFilter)
Format occurrences of matched text.
|
SearchArgs.Builder<K> |
highlightField(String field)
Convenience method to build
HighlightArgs
Add a field to highlight. |
SearchArgs.Builder<K> |
highlightTags(String startTag,
String endTag)
Convenience method to build
HighlightArgs
Tags to surround the matched terms with. |
SearchArgs.Builder<K> |
inField(String field)
Filter the result to those appearing only in specific attributes of the document.
|
SearchArgs.Builder<K> |
inKey(K key)
Limit the result to a given set of keys specified in the list.
|
SearchArgs.Builder<K> |
inOrder()
Require the terms in the document to have the same order as the terms in the query, regardless of the offsets between
them.
|
SearchArgs.Builder<K> |
language(DocumentLanguage language)
Specify the language of the query.
|
SearchArgs.Builder<K> |
limit(long offset,
long number)
Limit the results to the offset and number of results given.
|
SearchArgs.Builder<K> |
noContent()
Returns the document ids and not the content.
|
SearchArgs.Builder<K> |
param(String name,
byte[] value)
Add a binary query parameter, for example the query vector of a KNN clause (
*=>[KNN 10 @embedding $vec]). |
SearchArgs.Builder<K> |
param(String name,
String value)
Add a query parameter.
|
SearchArgs.Builder<K> |
returnField(String field)
Limit the attributes returned from the document.
|
SearchArgs.Builder<K> |
returnField(String field,
String as)
Limit the attributes returned from the document.
|
SearchArgs.Builder<K> |
scorer(ScoringFunction scorer)
Use a built-in or a user-provided scoring function
|
SearchArgs.Builder<K> |
slop(long slop)
Allow for a number of intermediate terms allowed to appear between the terms of the query.
|
SearchArgs.Builder<K> |
sortBy(SortByArgs sortBy)
Order the results by the value of this attribute.
|
SearchArgs.Builder<K> |
summarizeArgs(SummarizeArgs summarizeFilter)
Return only the sections of the attribute that contain the matched text.
|
SearchArgs.Builder<K> |
summarizeField(String field)
Convenience method to build
SummarizeArgs
Add a field to summarize. |
SearchArgs.Builder<K> |
summarizeFragments(long fragments)
Convenience method to build
SummarizeArgs
Set the number of fragments to be returned. |
SearchArgs.Builder<K> |
summarizeLen(long len)
Convenience method to build
SummarizeArgs
Set the number of context words each fragment should contain. |
SearchArgs.Builder<K> |
summarizeSeparator(String separator)
Convenience method to build
SummarizeArgs
The string used to divide individual summary snippets. |
SearchArgs.Builder<K> |
timeout(Duration timeout)
Override the maximum time to wait for the query to complete.
|
SearchArgs.Builder<K> |
verbatim()
Do not try to use stemming for query expansion but searches the query terms verbatim.
|
SearchArgs.Builder<K> |
withScores()
Return the relative internal score of each document.
|
SearchArgs.Builder<K> |
withSortKeys()
Return the value of the sorting key of each document, exposed through
SearchReply.SearchResult.getSortKey(). |
public SearchArgs<K> build()
SearchArgs.SearchArgspublic SearchArgs.Builder<K> noContent()
SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> verbatim()
SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> withScores()
SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> withSortKeys()
SearchReply.SearchResult.getSortKey(). This is usually not needed, and exists for
distributed search coordination purposes (merging sorted results from several indexes or shards). This option is
relevant only if used in conjunction with sortBy(SortByArgs): without SORTBY every result
has a null sort key. Disabled by default.SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> inKey(K key)
key - the key to search inSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> inField(String field)
field - the field to search inSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> returnField(String field, String as)
as is the name of the field used in the result as an alias.
Fields are requested in the order in which they are added. Adding a field that was already added replaces its alias but keeps its position.
field - the field to returnas - the alias to use for this field in the resultSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> returnField(String field)
Fields are requested in the order in which they are added.
field - the field to returnSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> summarizeArgs(SummarizeArgs summarizeFilter)
summarizeFilter - the summarization filterSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> summarizeField(String field)
SummarizeArgs
Add a field to summarize. Each field is summarized. If no FIELDS directive is passed, then all returned fields are summarized.
field - the field to addSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> summarizeLen(long len)
SummarizeArgs
Set the number of context words each fragment should contain. Context words surround the found term. A higher value will return a larger block of text. If not specified, the default value is 20.
len - the field to addSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> summarizeSeparator(String separator)
SummarizeArgs
The string used to divide individual summary snippets. The default is ... which is common among search
engines, but you may override this with any other string if you desire to programmatically divide the snippets later
on. You may also use a newline sequence, as newlines are stripped from the result body during processing.
separator - the separator between fragmentsSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> summarizeFragments(long fragments)
SummarizeArgs
Set the number of fragments to be returned. If not specified, the default is 3.
fragments - the number of fragments to returnSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> highlightArgs(HighlightArgs highlightFilter)
highlightFilter - the highlighting filterSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> highlightField(String field)
HighlightArgs
Add a field to highlight. If no FIELDS directive is passed, then all returned fields are highlighted.
field - the field to summarizeSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> highlightTags(String startTag, String endTag)
HighlightArgs
Tags to surround the matched terms with. If no TAGS are specified, a built-in tag pair is prepended and appended to each matched term.
startTag - the string is prepended to each matched termendTag - the string is appended to each matched termSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> slop(long slop)
hello world, if some other terms appear in-between hello and
world, a SLOP greater than 0 allows for these text attributes to match. By default, there is no SLOP
constraint.slop - the slop value how many intermediate terms are allowedSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> inOrder()
slop(long). Disabled by default.SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> language(DocumentLanguage language)
DocumentLanguage.ENGLISH.
If this setting was specified as part of index creation, it doesn't need to be specified here.language - the language of the querySearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> expander(String expander)
expander - the query expander to useSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> scorer(ScoringFunction scorer)
scorer - the ScoringFunction to useSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> sortBy(SortByArgs sortBy)
sortBy - the SortByArgs to useSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> limit(long offset, long number)
offset - the offset to usenumber - the limit to useSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> timeout(Duration timeout)
timeout - the timeout to use (with millisecond resolution)SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> param(String name, String value)
$name and the server substitutes the value wherever that
reference appears, so values need no escaping and cannot alter the query structure, for example
param("category", "electronics") with the query @category:{$category}. The value is sent as UTF-8
text. Adding a parameter with the same name again replaces its value.
Requires QueryDialects.DIALECT2 or higher.
name - the parameter name, referenced as $name in the query, must not be nullvalue - the parameter value, must not be nullSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> param(String name, byte[] value)
*=>[KNN 10 @embedding $vec]). The
bytes are sent exactly as given, which the String overload cannot do for arbitrary binary data. The query
references the parameter as $name; adding a parameter with the same name again replaces its value.
Requires QueryDialects.DIALECT2 or higher.
name - the parameter name, referenced as $name in the query, must not be nullvalue - the binary parameter value, sent as-is, must not be nullSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K> dialect(QueryDialects dialect)
QueryDialects.DIALECT2.dialect - the dialect to useSearchArgs.Builder for the purpose of method chainingQueryDialectsCopyright © 2026 lettuce.io. All rights reserved.