Package dev.langchain4j.web.search
Class WebSearchOrganicResult
java.lang.Object
dev.langchain4j.web.search.WebSearchOrganicResult
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 Summary
ConstructorsConstructorDescriptionWebSearchOrganicResult(String title, URI url) Constructs a WebSearchOrganicResult object with the given title and URL.WebSearchOrganicResult(String title, URI url, String snippet, String content) Constructs a WebSearchOrganicResult object with the given title, URL, snippet and/or content.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. -
Method Summary
Modifier and TypeMethodDescriptioncontent()Returns the content scraped from the web page.booleanstatic WebSearchOrganicResultCreates a WebSearchOrganicResult object from the given title and URL.static WebSearchOrganicResultCreates a WebSearchOrganicResult object from the given title, URL, snippet and/or content.static WebSearchOrganicResultCreates a WebSearchOrganicResult object from the given title, URL, snippet and/or content, and result metadata.inthashCode()metadata()Returns the result metadata associated with the search result.snippet()Returns the snippet associated with the web page.title()Returns the title of the web page.Converts this WebSearchOrganicResult to a Document.toString()Converts this WebSearchOrganicResult to a TextSegment.url()Returns the URL associated with the web page.
-
Constructor Details
-
WebSearchOrganicResult
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
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
Returns the title of the web page.- Returns:
- The title of the web page.
-
url
Returns the URL associated with the web page.- Returns:
- The URL associated with the web page.
-
snippet
Returns the snippet associated with the web page.- Returns:
- The snippet associated with the web page.
-
content
Returns the content scraped from the web page.- Returns:
- The content scraped from the web page.
-
metadata
Returns the result metadata associated with the search result.- Returns:
- The result metadata associated with the search result.
-
equals
-
hashCode
public int hashCode() -
toString
-
toTextSegment
Converts this WebSearchOrganicResult to a TextSegment.- Returns:
- The TextSegment representation of this WebSearchOrganicResult.
-
toDocument
Converts this WebSearchOrganicResult to a Document.- Returns:
- The Document representation of this WebSearchOrganicResult.
-
from
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
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.
-