类 WebSearchResults

java.lang.Object
dev.langchain4j.web.search.WebSearchResults

public class WebSearchResults extends Object
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.

  • 构造器详细资料

    • WebSearchResults

      public WebSearchResults(WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results)
      Constructs a new instance of WebSearchResults.
      参数:
      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.
      参数:
      searchMetadata - The metadata associated with the web search.
      searchInformation - The information about the web search.
      results - The list of organic search results.
  • 方法详细资料

    • searchMetadata

      public Map<String,Object> searchMetadata()
      Gets the metadata associated with the web search.
      返回:
      The metadata associated with the web search.
    • searchInformation

      public WebSearchInformationResult searchInformation()
      Gets the information about the web search.
      返回:
      The information about the web search.
    • results

      public List<WebSearchOrganicResult> results()
      Gets the list of organic search results.
      返回:
      The list of organic search results.
    • equals

      public boolean equals(Object o)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object
    • toTextSegments

      public List<TextSegment> toTextSegments()
      Converts the organic search results to a list of text segments.
      返回:
      The list of text segments.
    • toDocuments

      public List<Document> toDocuments()
      Converts the organic search results to a list of documents.
      返回:
      The list of documents.
    • from

      public static WebSearchResults from(WebSearchInformationResult searchInformation, List<WebSearchOrganicResult> results)
      Creates a new instance of WebSearchResults from the specified parameters.
      参数:
      results - The list of organic search results.
      searchInformation - The information about the web search.
      返回:
      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.
      参数:
      searchMetadata - The metadata associated with the search results.
      searchInformation - The information about the web search.
      results - The list of organic search results.
      返回:
      The new instance of WebSearchResults.