Class WebSearchOrganicResult

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

public class WebSearchOrganicResult extends Object
Represents an organic search results are the web pages that are returned by the search engine in response to a search query. This includes the title, URL, snippet and/or content, and metadata of the web page.

These results are typically ranked by relevance to the search query.

  • Constructor Details

    • WebSearchOrganicResult

      public WebSearchOrganicResult(String title, URI url)
      Constructs a WebSearchOrganicResult object with the given title and URL.
      Parameters:
      title - The title of the search result.
      url - The URL associated with the search result.
    • WebSearchOrganicResult

      public WebSearchOrganicResult(String title, URI url, String snippet, String content)
      Constructs a WebSearchOrganicResult object with the given title, URL, snippet and/or content.
      Parameters:
      title - The title of the search result.
      url - The URL associated with the search result.
      snippet - The snippet of the search result, in plain text.
      content - The most query related content from the scraped url.
    • WebSearchOrganicResult

      public WebSearchOrganicResult(String title, URI url, String snippet, String content, Map<String,String> metadata)
      Constructs a WebSearchOrganicResult object with the given title, URL, snippet and/or content, and metadata.
      Parameters:
      title - The title of the search result.
      url - The URL associated with the search result.
      snippet - The snippet of the search result, in plain text.
      content - The most query related content from the scraped url.
      metadata - The metadata associated with the search result.
  • Method Details

    • title

      public String title()
      Returns the title of the web page.
      Returns:
      The title of the web page.
    • url

      public URI url()
      Returns the URL associated with the web page.
      Returns:
      The URL associated with the web page.
    • snippet

      public String snippet()
      Returns the snippet associated with the web page.
      Returns:
      The snippet associated with the web page.
    • content

      public String content()
      Returns the content scraped from the web page.
      Returns:
      The content scraped from the web page.
    • metadata

      public Map<String,String> metadata()
      Returns the result metadata associated with the search result.
      Returns:
      The result metadata associated with the search result.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toTextSegment

      public TextSegment toTextSegment()
      Converts this WebSearchOrganicResult to a TextSegment.
      Returns:
      The TextSegment representation of this WebSearchOrganicResult.
    • toDocument

      public Document toDocument()
      Converts this WebSearchOrganicResult to a Document.
      Returns:
      The Document representation of this WebSearchOrganicResult.
    • from

      public static WebSearchOrganicResult from(String title, URI url)
      Creates a WebSearchOrganicResult object from the given title and URL.
      Parameters:
      title - The title of the search result.
      url - The URL associated with the search result.
      Returns:
      The created WebSearchOrganicResult object.
    • from

      public static WebSearchOrganicResult from(String title, URI url, String snippet, String content)
      Creates a WebSearchOrganicResult object from the given title, URL, snippet and/or content.
      Parameters:
      title - The title of the search result.
      url - The URL associated with the search result.
      snippet - The snippet of the search result, in plain text.
      content - The most query related content from the scraped url.
      Returns:
      The created WebSearchOrganicResult object.
    • from

      public static WebSearchOrganicResult from(String title, URI url, String snippet, String content, Map<String,String> metadata)
      Creates a WebSearchOrganicResult object from the given title, URL, snippet and/or content, and result metadata.
      Parameters:
      title - The title of the search result.
      url - The URL associated with the search result.
      snippet - The snippet of the search result, in plain text.
      content - The most query related content from the scraped url.
      metadata - The metadata associated with the search result.
      Returns:
      The created WebSearchOrganicResult object.