rok-search-macros
Proc-macro crate providing
#[derive(Searchable)]for rok-search.
Part of the Rok Framework — a full-stack Rust web framework built on Axum 0.8 and SQLx 0.8.
Features
#[derive(Searchable)]— implements theSearchabletrait for any struct#[search(index = "...")]container attribute to name the search index#[search(weight = "A"|"B"|"C"|"D")]field attribute for PostgreSQL FTS ranking#[search(filterable)]field attribute to mark fields usable in filter expressions#[search(skip)]field attribute to exclude a field from the search index- Zero runtime cost — all reflection happens at compile time
Installation
Do not add
rok-search-macrosdirectly. Userok-searchinstead — it re-exports the derive macro.
[]
= { = "0.2", = ["meilisearch"] }
Usage
use Searchable;
Core API
The #[derive(Searchable)] macro generates an implementation of the Searchable trait:
Integration
rok-search-macros is a private implementation detail of rok-search. The generated
Searchable impl is consumed by SearchDriver::index, SearchDriver::query, and
the ORM observer that keeps the index in sync with database writes.
If you need to implement Searchable manually (e.g. for a virtual document that combines
multiple tables), you can do so by implementing the trait directly without the derive macro:
use ;
License
MIT