From 398817ce7b5018a5ee7b8b0fc29c0c89efc29a77 Mon Sep 17 00:00:00 2001 From: PSeitz Date: Wed, 10 Apr 2024 08:09:09 +0200 Subject: [PATCH] add index sorting deprecation warning (#2353) * add index sorting deprecation warning * remove deprecated IntOptions and DatePrecision --- common/src/datetime.rs | 5 ----- common/src/lib.rs | 2 -- src/index/index.rs | 7 ++----- src/index/index_meta.rs | 4 ++++ src/lib.rs | 5 +++-- src/schema/date_time_options.rs | 2 -- src/schema/document/de.rs | 2 +- src/schema/mod.rs | 4 ---- src/schema/numeric_options.rs | 4 ---- 9 files changed, 10 insertions(+), 25 deletions(-) diff --git a/common/src/datetime.rs b/common/src/datetime.rs index 945856e077..0dd80b1478 100644 --- a/common/src/datetime.rs +++ b/common/src/datetime.rs @@ -1,5 +1,3 @@ -#![allow(deprecated)] - use std::fmt; use std::io::{Read, Write}; @@ -27,9 +25,6 @@ pub enum DateTimePrecision { Nanoseconds, } -#[deprecated(since = "0.20.0", note = "Use `DateTimePrecision` instead")] -pub type DatePrecision = DateTimePrecision; - /// A date/time value with nanoseconds precision. /// /// This timestamp does not carry any explicit time zone information. diff --git a/common/src/lib.rs b/common/src/lib.rs index 054378ee55..395ad24be6 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -15,8 +15,6 @@ mod vint; mod writer; pub use bitset::*; pub use byte_count::ByteCount; -#[allow(deprecated)] -pub use datetime::DatePrecision; pub use datetime::{DateTime, DateTimePrecision}; pub use group_by::GroupByIteratorExtended; pub use json_path_writer::JsonPathWriter; diff --git a/src/index/index.rs b/src/index/index.rs index ce68d4b13c..8d1281c178 100644 --- a/src/index/index.rs +++ b/src/index/index.rs @@ -83,7 +83,7 @@ fn save_new_metas( /// /// ``` /// use tantivy::schema::*; -/// use tantivy::{Index, IndexSettings, IndexSortByField, Order}; +/// use tantivy::{Index, IndexSettings}; /// /// let mut schema_builder = Schema::builder(); /// let id_field = schema_builder.add_text_field("id", STRING); @@ -96,10 +96,7 @@ fn save_new_metas( /// /// let schema = schema_builder.build(); /// let settings = IndexSettings{ -/// sort_by_field: Some(IndexSortByField{ -/// field: "number".to_string(), -/// order: Order::Asc -/// }), +/// docstore_blocksize: 100_000, /// ..Default::default() /// }; /// let index = Index::builder().schema(schema).settings(settings).create_in_ram(); diff --git a/src/index/index_meta.rs b/src/index/index_meta.rs index d0b649586b..f478ac2fde 100644 --- a/src/index/index_meta.rs +++ b/src/index/index_meta.rs @@ -288,6 +288,10 @@ impl Default for IndexSettings { /// Presorting documents can greatly improve performance /// in some scenarios, by applying top n /// optimizations. +#[deprecated( + since = "0.22.0", + note = "We plan to remove index sorting in `0.23`. If you need index sorting, please comment on the related issue https://github.com/quickwit-oss/tantivy/issues/2352 and explain your use case." +)] #[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] pub struct IndexSortByField { /// The field to sort the documents by diff --git a/src/lib.rs b/src/lib.rs index fa6b06755a..d087c96faf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,6 +178,7 @@ pub use crate::future_result::FutureResult; pub type Result = std::result::Result; mod core; +#[allow(deprecated)] // Remove with index sorting pub mod indexer; #[allow(unused_doc_comments)] @@ -189,6 +190,7 @@ pub mod collector; pub mod directory; pub mod fastfield; pub mod fieldnorm; +#[allow(deprecated)] // Remove with index sorting pub mod index; pub mod positions; pub mod postings; @@ -223,6 +225,7 @@ pub use self::snippet::{Snippet, SnippetGenerator}; pub use crate::core::json_utils; pub use crate::core::{Executor, Searcher, SearcherGeneration}; pub use crate::directory::Directory; +#[allow(deprecated)] // Remove with index sorting pub use crate::index::{ Index, IndexBuilder, IndexMeta, IndexSettings, IndexSortByField, InvertedIndexReader, Order, Segment, SegmentComponent, SegmentId, SegmentMeta, SegmentReader, @@ -234,8 +237,6 @@ pub use crate::index::{ pub use crate::indexer::PreparedCommit; pub use crate::indexer::{IndexWriter, SingleSegmentIndexWriter}; pub use crate::postings::Postings; -#[allow(deprecated)] -pub use crate::schema::DatePrecision; pub use crate::schema::{DateOptions, DateTimePrecision, Document, TantivyDocument, Term}; /// Index format version. diff --git a/src/schema/date_time_options.rs b/src/schema/date_time_options.rs index c6c03d795c..44465a409f 100644 --- a/src/schema/date_time_options.rs +++ b/src/schema/date_time_options.rs @@ -1,7 +1,5 @@ use std::ops::BitOr; -#[allow(deprecated)] -pub use common::DatePrecision; pub use common::DateTimePrecision; use serde::{Deserialize, Serialize}; diff --git a/src/schema/document/de.rs b/src/schema/document/de.rs index e38486ab18..657ad1430b 100644 --- a/src/schema/document/de.rs +++ b/src/schema/document/de.rs @@ -160,7 +160,7 @@ pub enum ValueType { /// A dynamic object value. Object, /// A JSON object value. Deprecated. - #[deprecated] + #[deprecated(note = "We keep this for backwards compatibility, use Object instead")] JSONObject, } diff --git a/src/schema/mod.rs b/src/schema/mod.rs index ced9a4b8ce..33435c943d 100644 --- a/src/schema/mod.rs +++ b/src/schema/mod.rs @@ -130,8 +130,6 @@ mod text_options; use columnar::ColumnType; pub use self::bytes_options::BytesOptions; -#[allow(deprecated)] -pub use self::date_time_options::DatePrecision; pub use self::date_time_options::{DateOptions, DateTimePrecision, DATE_TIME_PRECISION_INDEXED}; pub use self::document::{DocParsingError, Document, OwnedValue, TantivyDocument, Value}; pub(crate) use self::facet::FACET_SEP_BYTE; @@ -146,8 +144,6 @@ pub use self::index_record_option::IndexRecordOption; pub use self::ip_options::{IntoIpv6Addr, IpAddrOptions}; pub use self::json_object_options::JsonObjectOptions; pub use self::named_field_document::NamedFieldDocument; -#[allow(deprecated)] -pub use self::numeric_options::IntOptions; pub use self::numeric_options::NumericOptions; pub use self::schema::{Schema, SchemaBuilder}; pub use self::term::{Term, ValueBytes, JSON_END_OF_PATH}; diff --git a/src/schema/numeric_options.rs b/src/schema/numeric_options.rs index 432e5563ec..db36b523ec 100644 --- a/src/schema/numeric_options.rs +++ b/src/schema/numeric_options.rs @@ -5,10 +5,6 @@ use serde::{Deserialize, Serialize}; use super::flags::CoerceFlag; use crate::schema::flags::{FastFlag, IndexedFlag, SchemaFlagList, StoredFlag}; -#[deprecated(since = "0.17.0", note = "Use NumericOptions instead.")] -/// Deprecated use [`NumericOptions`] instead. -pub type IntOptions = NumericOptions; - /// Define how an `u64`, `i64`, or `f64` field should be handled by tantivy. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(from = "NumericOptionsDeser")]