From bfb46cbfbe1eea9a6b19b94ff0b43b43e7c9a56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 12 Aug 2020 10:43:02 +0200 Subject: [PATCH] Introduce the Crtierion enum --- src/criterion.rs | 31 +++++++++++++++++++++++++++++++ src/lib.rs | 1 + 2 files changed, 32 insertions(+) create mode 100644 src/criterion.rs diff --git a/src/criterion.rs b/src/criterion.rs new file mode 100644 index 000000000..fd334f7d9 --- /dev/null +++ b/src/criterion.rs @@ -0,0 +1,31 @@ +pub enum Criterion { + /// Sorted by increasing number of typos. + Typo, + /// Sorted by decreasing number of matched query terms. + Words, + /// Sorted by increasing distance between matched query terms. + Proximity, + /// Documents with quey words contained in more important + /// attributes are considred better. + Attribute, + /// Documents with query words at the front of an attribute is + /// considered better than if it was at the back. + WordsPosition, + /// Sorted by the similarity of the matched words with the query words. + Exactness, + /// Sorted by the increasing value of the field specified. + CustomAsc(String), + /// Sorted by the decreasing value of the field specified. + CustomDesc(String), +} + +pub fn default_criteria() -> Vec { + vec![ + Criterion::Typo, + Criterion::Words, + Criterion::Proximity, + Criterion::Attribute, + Criterion::WordsPosition, + Criterion::Exactness, + ] +} diff --git a/src/lib.rs b/src/lib.rs index 6ec02433e..63d0ed6c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ mod best_proximity; +mod criterion; mod heed_codec; mod iter_shortest_paths; mod query_tokens;