Package dev.langchain4j.web.search
Class WebSearchRequest
java.lang.Object
dev.langchain4j.web.search.WebSearchRequest
Represents a search request that can be made by the user to perform searches in any implementation of
WebSearchEngine
.
WebSearchRequest
follow opensearch foundation standard implemented by most web search engine libs like Google, Bing, Yahoo, etc.
OpenSearch#parameters
The searchTerms
are the keywords that the search client desires to search for. This param is mandatory to perform a search.
Configurable parameters (optional):
maxResults
- The expected number of results to be found if the search request were made. Each search engine may have a different limit for the maximum number of results that can be returned.language
- The desired language for search results is a string that indicates that the search client desires search results in the specified language. Each search engine may have a different set of supported languages.geoLocation
- The desired geolocation for search results is a string that indicates that the search client desires search results in the specified geolocation. Each search engine may have a different set of supported geolocations.startPage
- The start page number for search results is the page number of the set of search results desired by the search user.startIndex
- The start index for search results is the index of the first search result desired by the search user. Each search engine may have a different set of supported start indexes in combination with the start page number.safeSearch
- The safe search flag is a boolean that indicates that the search client desires search results with safe search enabled or disabled.additionalParams
- The additional parameters for the search request are a map of key-value pairs that represent additional parameters for the search request. It's a way to be flex and add custom param for each search engine.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the additional parameters for the search request.static WebSearchRequest.Builder
builder()
Create a new builder instance.boolean
static WebSearchRequest
Create a web search request with the given search terms.static WebSearchRequest
Create a web search request with the given search terms and maximum number of results.Get the desired geolocation for search results.int
hashCode()
language()
Get the desired language for search results.Get the maximum number of results.Get the safe search flag.Get the search terms.Get the start index for search results.Get the start page number for search results.toString()
-
Method Details
-
searchTerms
Get the search terms.- Returns:
- The search terms.
-
maxResults
Get the maximum number of results.- Returns:
- The maximum number of results.
-
language
Get the desired language for search results.- Returns:
- The desired language for search results.
-
geoLocation
Get the desired geolocation for search results.- Returns:
- The desired geolocation for search results.
-
startPage
Get the start page number for search results.- Returns:
- The start page number for search results.
-
startIndex
Get the start index for search results.- Returns:
- The start index for search results.
-
safeSearch
Get the safe search flag.- Returns:
- The safe search flag.
-
additionalParams
Get the additional parameters for the search request.- Returns:
- The additional parameters for the search request.
-
equals
-
hashCode
public int hashCode() -
toString
-
builder
Create a new builder instance.- Returns:
- A new builder instance.
-
from
Create a web search request with the given search terms.- Parameters:
searchTerms
- The search terms.- Returns:
- The web search request.
-
from
Create a web search request with the given search terms and maximum number of results.- Parameters:
searchTerms
- The search terms.maxResults
- The maximum number of results.- Returns:
- The web search request.
-