pallet

Docs Crates.io

A searchable document datastore built on sled and tantivy.

Provides a typed-tree interface to a sled database, with standard datastore ops (find, create, update, delete), but also Lucene/Elasticsearch style searching.

The included pallet_macros crate provides an easy way to derive pallet::DocumentLike for data structs.

Usage

```rust

[macro_use]

extern crate serde;

[derive(Serialize, Deserialize, Debug, pallet::DocumentLike)]

[pallet(tree_name = "books")]

pub struct Book { #[pallet(defaultsearchfield)] title: String, #[pallet(defaultsearchfield)] description: Option, #[pallet(indexfieldtype = "u64")] rating: u8, }

fn main() -> Result<(), Box> { let tempdir = tempfile::TempDir::newin(".")?;

let db = sled::open(temp_dir.path().join("db"))?;

let store = pallet::Store::builder().with_db(db).with_index_dir(temp_dir.path()).finish()?;

let books = vec![
    Book {
        title: "The Old Man and the Sea".into(),
        description: Some(
            "He was an old man who fished alone in a skiff in \
        the Gulf Stream and he had gone eighty-four days \
        now without taking a fish."
                .into(),
        ),
        rating: 10,
    },
    Book {
        title: "The Great Gatsby".into(),
        description: Some("About a man and some other stuff".into()),
        rating: 8,
    },
];

let _ = store.create_multi(&books)?;

let books = store.search("man AND rating:>8")?;

println!("{:?}", books);

Ok(())

} ```

pallet_macros

See the example for usage. The following attributes can be used to customize the implementation:

Changelog

0.4.0

0.3.2

0.3.0


Current version: 0.4.0

License: MIT