Package dev.langchain4j.web.search
Class WebSearchResults
java.lang.Object
dev.langchain4j.web.search.WebSearchResults
Represents the response of a web search performed.
This includes the list of organic search results, information about the search, and pagination information.
WebSearchResults
follow opensearch foundation standard implemented by most web search engine libs like Google, Bing, Yahoo, etc.
OpenSearch#response
The organic search results are the web pages that are returned by the search engine in response to a search query. These results are typically ranked by relevance to the search query.
-
Constructor Summary
ConstructorDescriptionWebSearchResults
(WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results) Constructs a new instance of WebSearchResults.WebSearchResults
(Map<String, Object> searchMetadata, WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results) Constructs a new instance of WebSearchResults. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static WebSearchResults
from
(WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results) Creates a new instance of WebSearchResults from the specified parameters.static WebSearchResults
from
(Map<String, Object> searchMetadata, WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results) Creates a new instance of WebSearchResults from the specified parameters.int
hashCode()
results()
Gets the list of organic search results.Gets the information about the web search.Gets the metadata associated with the web search.Converts the organic search results to a list of documents.toString()
Converts the organic search results to a list of text segments.
-
Constructor Details
-
WebSearchResults
public WebSearchResults(WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results) Constructs a new instance of WebSearchResults.- Parameters:
searchInformation
- The information about the web search.results
- The list of organic search results.
-
WebSearchResults
public WebSearchResults(Map<String, Object> searchMetadata, WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results) Constructs a new instance of WebSearchResults.- Parameters:
searchMetadata
- The metadata associated with the web search.searchInformation
- The information about the web search.results
- The list of organic search results.
-
-
Method Details
-
searchMetadata
Gets the metadata associated with the web search.- Returns:
- The metadata associated with the web search.
-
searchInformation
Gets the information about the web search.- Returns:
- The information about the web search.
-
results
Gets the list of organic search results.- Returns:
- The list of organic search results.
-
equals
-
hashCode
public int hashCode() -
toString
-
toTextSegments
Converts the organic search results to a list of text segments.- Returns:
- The list of text segments.
-
toDocuments
Converts the organic search results to a list of documents.- Returns:
- The list of documents.
-
from
public static WebSearchResults from(WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results) Creates a new instance of WebSearchResults from the specified parameters.- Parameters:
searchInformation
- The information about the web search.results
- The list of organic search results.- Returns:
- The new instance of WebSearchResults.
-
from
public static WebSearchResults from(Map<String, Object> searchMetadata, WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results) Creates a new instance of WebSearchResults from the specified parameters.- Parameters:
searchMetadata
- The metadata associated with the search results.searchInformation
- The information about the web search.results
- The list of organic search results.- Returns:
- The new instance of WebSearchResults.
-