Skip to main content

Searchable

Trait Searchable 

Source
pub trait Searchable {
    const INDEX_NAME: &'static str;
    const SEARCHABLE_ATTRIBUTES: &'static [&'static str];
    const PRIMARY_KEY: &'static str = "id";
    const FILTERABLE_ATTRIBUTES: &'static [&'static str] = _;
    const SORTABLE_ATTRIBUTES: &'static [&'static str] = _;
    const FACETABLE_ATTRIBUTES: &'static [&'static str] = _;

    // Required method
    fn to_search_doc(&self) -> Value;
}

Required Associated Constants§

Source

const INDEX_NAME: &'static str

Index name — typically the same as the admin name (“posts”).

Source

const SEARCHABLE_ATTRIBUTES: &'static [&'static str]

Which attributes the engine should actually tokenise for full-text queries. Fewer is faster; only include what users would actually type to find this model.

Provided Associated Constants§

Source

const PRIMARY_KEY: &'static str = "id"

Primary key field in the serialised document. Meilisearch requires one unique key per doc; for us it’s almost always “id”.

Source

const FILTERABLE_ATTRIBUTES: &'static [&'static str] = _

Fields available for filter=… queries (e.g. published=true).

Source

const SORTABLE_ATTRIBUTES: &'static [&'static str] = _

Fields available for sort=….

Source

const FACETABLE_ATTRIBUTES: &'static [&'static str] = _

Subset of filterable attributes to request facet counts for. A UI with a “by author” sidebar wants author here; a raw created_at timestamp that’s filterable-but-not-faceted does not.

Required Methods§

Source

fn to_search_doc(&self) -> Value

Serialise self into the JSON document shape Meili indexes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§