Class WebSearchRequest
-
- All Implemented Interfaces:
public class WebSearchRequestRepresents 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
Nested Classes Modifier and Type Class Description public final classWebSearchRequest.Builder
-
Method Summary
Modifier and Type Method Description StringsearchTerms()Get the search terms. IntegermaxResults()Get the maximum number of results. Stringlanguage()Get the desired language for search results. StringgeoLocation()Get the desired geolocation for search results. IntegerstartPage()Get the start page number for search results. IntegerstartIndex()Get the start index for search results. BooleansafeSearch()Get the safe search flag. Map<String, Object>additionalParams()Get the additional parameters for the search request. booleanequals(Object another)inthashCode()StringtoString()static WebSearchRequest.Builderbuilder()Create a new builder instance. static WebSearchRequestfrom(String searchTerms)Create a web search request with the given search terms. static WebSearchRequestfrom(String searchTerms, Integer maxResults)Create a web search request with the given search terms and maximum number of results. -
-
Method Detail
-
searchTerms
String searchTerms()
Get the search terms.
- Returns:
The search terms.
-
maxResults
Integer maxResults()
Get the maximum number of results.
- Returns:
The maximum number of results.
-
language
String language()
Get the desired language for search results.
- Returns:
The desired language for search results.
-
geoLocation
String geoLocation()
Get the desired geolocation for search results.
- Returns:
The desired geolocation for search results.
-
startPage
Integer startPage()
Get the start page number for search results.
- Returns:
The start page number for search results.
-
startIndex
Integer startIndex()
Get the start index for search results.
- Returns:
The start index for search results.
-
safeSearch
Boolean safeSearch()
Get the safe search flag.
- Returns:
The safe search flag.
-
additionalParams
Map<String, Object> additionalParams()
Get the additional parameters for the search request.
- Returns:
The additional parameters for the search request.
-
hashCode
int hashCode()
-
builder
static WebSearchRequest.Builder builder()
Create a new builder instance.
- Returns:
A new builder instance.
-
from
static WebSearchRequest from(String searchTerms)
Create a web search request with the given search terms.
- Parameters:
searchTerms- The search terms.- Returns:
The web search request.
-
from
static WebSearchRequest from(String searchTerms, Integer maxResults)
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.
-
-
-
-