K - the key typeV - the value typepublic static class SearchArgs.Builder<K,V> 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,V> |
build()
Build a new instance of the
SearchArgs. |
SearchArgs.Builder<K,V> |
dialect(QueryDialects dialect)
Set the query dialect.
|
SearchArgs.Builder<K,V> |
expander(V expander)
Use a custom query expander instead of the stemmer
|
SearchArgs.Builder<K,V> |
highlightArgs(HighlightArgs<K,V> highlightFilter)
Format occurrences of matched text.
|
SearchArgs.Builder<K,V> |
highlightField(K field)
Convenience method to build
HighlightArgs
Add a field to highlight. |
SearchArgs.Builder<K,V> |
highlightTags(V startTag,
V endTag)
Convenience method to build
HighlightArgs
Tags to surround the matched terms with. |
SearchArgs.Builder<K,V> |
inField(K field)
Filter the result to those appearing only in specific attributes of the document.
|
SearchArgs.Builder<K,V> |
inKey(K key)
Limit the result to a given set of keys specified in the list.
|
SearchArgs.Builder<K,V> |
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,V> |
language(DocumentLanguage language)
Specify the language of the query.
|
SearchArgs.Builder<K,V> |
limit(long offset,
long number)
Limit the results to the offset and number of results given.
|
SearchArgs.Builder<K,V> |
noContent()
Returns the document ids and not the content.
|
SearchArgs.Builder<K,V> |
param(K name,
V value)
Add one or more value parameters.
|
SearchArgs.Builder<K,V> |
returnField(K field)
Limit the attributes returned from the document.
|
SearchArgs.Builder<K,V> |
returnField(K field,
K as)
Limit the attributes returned from the document.
|
SearchArgs.Builder<K,V> |
scorer(ScoringFunction scorer)
Use a built-in or a user-provided scoring function
|
SearchArgs.Builder<K,V> |
slop(long slop)
Allow for a number of intermediate terms allowed to appear between the terms of the query.
|
SearchArgs.Builder<K,V> |
sortBy(SortByArgs<K> sortBy)
Order the results by the value of this attribute.
|
SearchArgs.Builder<K,V> |
summarizeArgs(SummarizeArgs<K,V> summarizeFilter)
Return only the sections of the attribute that contain the matched text.
|
SearchArgs.Builder<K,V> |
summarizeField(K field)
Convenience method to build
SummarizeArgs
Add a field to summarize. |
SearchArgs.Builder<K,V> |
summarizeFragments(long fragments)
Convenience method to build
SummarizeArgs
Set the number of fragments to be returned. |
SearchArgs.Builder<K,V> |
summarizeLen(long len)
Convenience method to build
SummarizeArgs
Set the number of context words each fragment should contain. |
SearchArgs.Builder<K,V> |
summarizeSeparator(V separator)
Convenience method to build
SummarizeArgs
The string used to divide individual summary snippets. |
SearchArgs.Builder<K,V> |
timeout(Duration timeout)
Override the maximum time to wait for the query to complete.
|
SearchArgs.Builder<K,V> |
verbatim()
Do not try to use stemming for query expansion but searches the query terms verbatim.
|
SearchArgs.Builder<K,V> |
withScores()
Return the relative internal score of each document.
|
SearchArgs.Builder<K,V> |
withSortKeys()
Return the value of the sorting key, right after the id and score and/or payload, if requested.
|
public SearchArgs<K,V> build()
SearchArgs.SearchArgspublic SearchArgs.Builder<K,V> noContent()
SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> verbatim()
SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> withScores()
SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> withSortKeys()
sortBy(SortByArgs). Disabled by default.SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> inKey(K key)
key - the key to search inSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> inField(K field)
field - the field to search inSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> returnField(K field, K as)
as is the name of the field used in the result as an alias.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,V> returnField(K field)
field - the field to returnSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> summarizeArgs(SummarizeArgs<K,V> summarizeFilter)
summarizeFilter - the summarization filterSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> summarizeField(K 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,V> 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,V> summarizeSeparator(V 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,V> 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,V> highlightArgs(HighlightArgs<K,V> highlightFilter)
highlightFilter - the highlighting filterSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> highlightField(K 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,V> highlightTags(V startTag, V 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,V> 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,V> inOrder()
slop(long). Disabled by default.SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> 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,V> expander(V expander)
expander - the query expander to useSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> scorer(ScoringFunction scorer)
scorer - the ScoringFunction to useSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> sortBy(SortByArgs<K> sortBy)
sortBy - the SortByArgs to useSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> limit(long offset, long number)
offset - the offset to usenumber - the limit to useSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> timeout(Duration timeout)
timeout - the timeout to use (with millisecond resolution)SearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> param(K name, V value)
QueryDialects.DIALECT2 or higher.name - the name of the parametervalue - the value of the parameterSearchArgs.Builder for the purpose of method chainingpublic SearchArgs.Builder<K,V> dialect(QueryDialects dialect)
QueryDialects.DIALECT2.dialect - the dialect to useSearchArgs.Builder for the purpose of method chainingQueryDialectsCopyright © 2025 lettuce.io. All rights reserved.