The interface encapsulating the various search engine backends. | (ns metabase.search.engine) |
Does this instance support the given engine? | (defmulti supported-engine?
{:arglists '([engine])}
identity) |
(defmethod supported-engine? :default [engine]
(throw (ex-info (format "Unknown search engine: %s" engine)
{:engine engine}))) | |
Return a reducible of the search result matching a given query. | (defmulti results
{:arglists '([search-context])}
:search-engine) |
Return a set of the models which have at least one result for the given query. | (defmulti model-set
{:arglists '([search-context])}
:search-engine) |
For legacy search: perform the in-memory ranking | (defmulti score
{:arglists '([search-context result])}
(fn [{engine :search-engine} _]
engine)) |
(defmethod score :default [_search-ctx result]
{:result (dissoc result :score)
:score (:score result)}) | |
Updates the search index by consuming the documents from the given reducible. | (defmulti consume!
{:arglists '([search-engine document-reducible])}
(fn [search-engine _document-reducible]
search-engine)) |
Removes the documents from the search index. | (defmulti delete!
{:arglists '([search-engine model ids])}
(fn [search-engine _model _ids]
search-engine)) |
Ensure that the search index exists, an is ready to take search queries. | (defmulti init!
{:arglists '([engine opts])}
(fn [engine _opts]
engine)) |
Perform a full refresh of the given engine's index. | (defmulti reindex!
{:arglists '([engine opts])}
(fn [engine _opts] engine)) |
Stop tracking the current indexes. Used when resetting the appdb. | (defmulti reset-tracking!
{:arglists '([engine])}
identity) |
List the possible search engines defined for this version, whether this instance supports them or not. | (defn known-engines [] ;; If we end up with more "abstract" nodes, we may want a better way to filter them out. (keys (dissoc (methods supported-engine?) :default))) |
List the search engines that are supported. Does not mention the legacy in-place engine. | (defn active-engines [] (for [[k p] (dissoc (methods supported-engine?) :default :search.engine/in-place) :when (p k)] k)) |
Is the given engine recognized? | (defn known-engine?
[engine]
(let [registered? #(contains? (methods supported-engine?) %)]
(some registered? (cons engine (ancestors engine))))) |