From dc141cdb2934b4142192eceaf28c078ea9fbbbec Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Fri, 13 Aug 2021 17:40:13 +0100 Subject: [PATCH] more docs detail remove code duplicate --- src/schema/field_entry.rs | 14 ++++---------- src/schema/flags.rs | 2 +- src/schema/int_options.rs | 4 +++- src/schema/text_options.rs | 4 ++-- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/schema/field_entry.rs b/src/schema/field_entry.rs index b7fb9973c..d25a4896d 100644 --- a/src/schema/field_entry.rs +++ b/src/schema/field_entry.rs @@ -109,17 +109,11 @@ impl FieldEntry { &self.field_type } - /// Returns true iff the field is indexed + /// Returns true iff the field is indexed. + /// + /// An indexed field is searchable. pub fn is_indexed(&self) -> bool { - match self.field_type { - FieldType::Str(ref options) => options.get_indexing_options().is_some(), - FieldType::U64(ref options) - | FieldType::I64(ref options) - | FieldType::F64(ref options) - | FieldType::Date(ref options) => options.is_indexed(), - FieldType::HierarchicalFacet(ref options) => options.is_indexed(), - FieldType::Bytes(ref options) => options.is_indexed(), - } + self.field_type.is_indexed() } /// Returns true iff the field is a int (signed or unsigned) fast field diff --git a/src/schema/flags.rs b/src/schema/flags.rs index 758e680f5..7c10e0c8b 100644 --- a/src/schema/flags.rs +++ b/src/schema/flags.rs @@ -20,7 +20,7 @@ pub const STORED: SchemaFlagList = SchemaFlagList { #[derive(Clone)] pub struct IndexedFlag; -/// Flag to mark the field as indexed. +/// Flag to mark the field as indexed. An indexed field is searchable. /// /// The `INDEXED` flag can only be used when building `IntOptions` (`u64`, `i64` and `f64` fields) /// Of course, text fields can also be indexed... But this is expressed by using either the diff --git a/src/schema/int_options.rs b/src/schema/int_options.rs index a5e3b86f2..b1ecd3d2d 100644 --- a/src/schema/int_options.rs +++ b/src/schema/int_options.rs @@ -29,7 +29,7 @@ impl IntOptions { self.stored } - /// Returns true iff the value is indexed. + /// Returns true iff the value is indexed and therefore searchable. pub fn is_indexed(&self) -> bool { self.indexed } @@ -52,6 +52,8 @@ impl IntOptions { /// /// Setting an integer as indexed will generate /// a posting list for each value taken by the integer. + /// + /// This is required for the field to be searchable. pub fn set_indexed(mut self) -> IntOptions { self.indexed = true; self diff --git a/src/schema/text_options.rs b/src/schema/text_options.rs index abb65e6dc..a1f47dfb7 100644 --- a/src/schema/text_options.rs +++ b/src/schema/text_options.rs @@ -94,7 +94,7 @@ impl TextFieldIndexing { } } -/// The field will be untokenized and indexed +/// The field will be untokenized and indexed. pub const STRING: TextOptions = TextOptions { indexing: Some(TextFieldIndexing { tokenizer: Cow::Borrowed("raw"), @@ -103,7 +103,7 @@ pub const STRING: TextOptions = TextOptions { stored: false, }; -/// The field will be tokenized and indexed +/// The field will be tokenized and indexed. pub const TEXT: TextOptions = TextOptions { indexing: Some(TextFieldIndexing { tokenizer: Cow::Borrowed("default"),