Crate attribute_search_engine

Source
Expand description

Attribute Search Engine is a generic search engine for rows consisting of attributes, that can be searched using different matchers.

§Overview

use attribute_search_engine::{SearchEngine, SearchIndexHashMap, SearchIndexBTreeRange};

// Before we can create a new engine we need some indices.
let mut index_name = SearchIndexHashMap::<_, String>::new();
let mut index_age = SearchIndexBTreeRange::<_, u8>::new();

// We add two persons:
index_name.insert(0, "Alice".into());
index_age.insert(0, 27);

index_name.insert(1, "Bob".into());
index_name.insert(1, "Bobby".into()); // One row can have multiple entries
index_age.insert(1, 25);

// Now we create the engine and add our indices to it:
let mut engine = SearchEngine::<usize>::new();
engine.add_index("name", index_name);
engine.add_index("age", index_age);

// TODO Manual Queries, Queries out of strings, Prefix-Index

§Which Index should I use?

QuerySearchIndexHashMapSearchIndexPrefixTreeSearchIndexBTreeRange
ExactYes ✔️Yes ✔️Yes ✔️
PrefixNo ❌Yes ✔️No ❌
InRangeNo ❌No ❌Yes ✔️
OutRangeNo ❌No ❌Yes ✔️
MinimumNo ❌No ❌Yes ✔️
MaximumNo ❌No ❌Yes ✔️
Orna1 🔷na1 🔷na1 🔷
Andna1 🔷na1 🔷na1 🔷
Excludena1 🔷na1 🔷na1 🔷

  1. Or, And & Exclude are only supported by SearchEngine and not the indices. 

Structs§

SearchEngine
A SearchEngine is a wrapper around a collection of search indices that can process complex queries involving multiple indices.
SearchIndexBTreeRange
SearchIndexBTreeRange is a index backed by a BTreeMap that can match Exact, InRange, OutRange, Minimum and Maximum queries.
SearchIndexHashMap
SearchIndexHashMap is a index backed by a HashMap that can match Exact queries.
SearchIndexPrefixTree
SearchIndexPrefixTree is a index backed by a prefix tree that can match Exact and Prefix queries. It can only store String attribute values.

Enums§

Query
Query is a recursive datatype that describes a query to a search index or engine.
SearchEngineError
Enum of all possible error types that the attribute search engine can throw by itself.

Traits§

SearchIndex
This trait describes the minimum features an Index must support to be usable as a SearchIndex, for example in a SearchEngine.

Type Aliases§

Result
Common Result type for the attribute search engine.