Liking cljdoc? Tell your friends :D

jj.bettong.search

Search backends: the functions the search capabilities are built on.

A backend is just (fn [{:keys [query max-results]}] -> [{:title :url :snippet}]), so anything can be one: a public search API, your own index, an internal wiki. The named ones below are conveniences.

Search backends: the functions the search capabilities are built on.

A backend is just (fn [{:keys [query max-results]}] -> [{:title :url :snippet}]),
so anything can be one: a public search API, your own index, an internal wiki.
The named ones below are conveniences.
raw docstring

braveclj

(brave {:keys [api-key timeout-ms base-url]})

https://brave.com/search/api - key: :api-key or BRAVE_API_KEY.

https://brave.com/search/api - key: :api-key or BRAVE_API_KEY.
raw docstring

default-max-resultsclj


default-timeout-msclj


duckduckgoclj

(duckduckgo {:keys [timeout-ms base-url]})

Scrapes DuckDuckGo's no-JavaScript endpoint. No API key, but it is a public HTML page: DuckDuckGo may answer with a bot challenge instead of results, in which case you get none. For anything load-bearing, use a keyed backend.

Scrapes DuckDuckGo's no-JavaScript endpoint. No API key, but it is a public
HTML page: DuckDuckGo may answer with a bot challenge instead of results,
in which case you get none. For anything load-bearing, use a keyed backend.
raw docstring

format-resultsclj

(format-results query results {:keys [snippet-length] :or {snippet-length 300}})

Renders results for the model: numbered, with the URL on its own line so it can be quoted back accurately.

Renders results for the model: numbered, with the URL on its own line so it
can be quoted back accurately.
raw docstring

googleclj

(google {:keys [api-key cx timeout-ms base-url]})

Google's official Custom Search JSON API.

Needs two things, both from https://developers.google.com/custom-search/v1/overview: :api-key an API key (or GOOGLE_API_KEY) :cx the id of a Programmable Search Engine (or GOOGLE_CSE_ID). Set that engine to 'Search the entire web' for general web search.

The free tier is 100 queries a day. Google caps num at 10 per request.

Google's official Custom Search JSON API.

Needs two things, both from https://developers.google.com/custom-search/v1/overview:
  :api-key  an API key      (or GOOGLE_API_KEY)
  :cx       the id of a Programmable Search Engine (or GOOGLE_CSE_ID). Set that
            engine to 'Search the entire web' for general web search.

The free tier is 100 queries a day. Google caps `num` at 10 per request.
raw docstring

parse-braveclj

(parse-brave body)

parse-duckduckgoclj

(parse-duckduckgo html)

Pulls results out of the html.duckduckgo.com results page.

Pulls results out of the html.duckduckgo.com results page.
raw docstring

parse-googleclj

(parse-google body)

parse-serperclj

(parse-serper body)

parse-tavilyclj

(parse-tavily body)

parse-wikipediaclj

(parse-wikipedia body)
(parse-wikipedia body site)

Article urls are built from the wiki that was searched, not a fixed one: a :language of "lt" searches lt.wikipedia, and its articles do not exist under en.wikipedia.

Article urls are built from the wiki that was searched, not a fixed one: a
:language of "lt" searches lt.wikipedia, and its articles do not exist under
en.wikipedia.
raw docstring

query-stringclj

(query-string params)

Builds a url-encoded query string. The JDK client takes a url, not a params map, so we assemble it here.

Builds a url-encoded query string. The JDK client takes a url, not a params
map, so we assemble it here.
raw docstring

serperclj

(serper {:keys [api-key timeout-ms base-url]})

https://serper.dev - Google results. Key: :api-key or SERPER_API_KEY.

https://serper.dev - Google results. Key: :api-key or SERPER_API_KEY.
raw docstring

strip-tagsclj

(strip-tags s)

Search snippets come back with <b> highlighting; drop the markup.

Search snippets come back with <b> highlighting; drop the markup.
raw docstring

tavilyclj

(tavily {:keys [api-key timeout-ms search-depth base-url]})

https://tavily.com - a search API built for LLMs. Key: :api-key or TAVILY_API_KEY.

https://tavily.com - a search API built for LLMs. Key: :api-key or TAVILY_API_KEY.
raw docstring

unescape-htmlclj

(unescape-html s)

Decodes the entities that turn up in search result titles and snippets.

Decodes the entities that turn up in search result titles and snippets.
raw docstring

wikipediaclj

(wikipedia {:keys [timeout-ms language base-url]})

Searches Wikipedia through the MediaWiki API. No key needed. :language picks the edition, and the urls returned point at it.

Searches Wikipedia through the MediaWiki API. No key needed.
`:language` picks the edition, and the urls returned point at it.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close