Skip to content

web search done right

rustup update and fix clippy

Mikkel Denkeree0fc39eaa18
diff --git a/crates/core/src/ampc/dht/mod.rs b/crates/core/src/ampc/dht/mod.rs
index 92036334..e3910068 100644
--- a/crates/core/src/ampc/dht/mod.rs
+++ b/crates/core/src/ampc/dht/mod.rs
@@ -15,8 +15,10 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Simple in-memory key-value store with Raft consensus where keys
-//! and values are arbitrary bytes. It is intended to be deployed
-//! across multiple nodes with multiple shards. Each shard cluster
+//! and values are arbitrary bytes.
+//!
+//! It is intended to be deployed across multiple nodes
+//! with multiple shards. Each shard cluster
//! is a Raft cluster, and each key is then routed to the correct
//! cluster based on hash(key) % number_of_shards. The keys
//! are currently *not* rebalanced if the number of shards change, so
diff --git a/crates/core/src/autosuggest.rs b/crates/core/src/autosuggest.rs
index 99b359a4..2640be66 100644
--- a/crates/core/src/autosuggest.rs
+++ b/crates/core/src/autosuggest.rs
@@ -16,6 +16,7 @@
//! Autosuggest provides the functionality for the little dropdown that appears
//! when you type something into the search bar and queries are suggested.
+//!
//! It uses a finite state transducer (fst) to store popular queries
//! and performs a prefix search on the fst to find suggestions.
diff --git a/crates/core/src/inverted_index/mod.rs b/crates/core/src/inverted_index/mod.rs
index 621084ed..3db081b5 100644
--- a/crates/core/src/inverted_index/mod.rs
+++ b/crates/core/src/inverted_index/mod.rs
@@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! The inverted index is the main data structure of the search engine.
+//!
//! It is a mapping from terms to a list of documents. Imagine a hash map
//! { term -> \[doc1, doc2, doc3\] } etc. During search, we look up the terms
//! from the query in the index and perform an intersection of the lists of
diff --git a/crates/file-store/src/iterable.rs b/crates/file-store/src/iterable.rs
index 212848f7..54abca10 100644
--- a/crates/file-store/src/iterable.rs
+++ b/crates/file-store/src/iterable.rs
@@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>
//! This module contains the implementation of the `IterableStoreWriter` and `IterableStoreReader`.
+//!
//! The iterable store is a simple format for storing a sequence of items in a file such that they
//! can be read back in order. The format is as follows:
//!
diff --git a/crates/file-store/src/peekable.rs b/crates/file-store/src/peekable.rs
index 1509ef65..5b76be57 100644
--- a/crates/file-store/src/peekable.rs
+++ b/crates/file-store/src/peekable.rs
@@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/
/// An iterator that allows peeking at the next element.
+///
/// Unlike the standard library's `Peekable`, this implementation
/// *is not* lazy and will always consume the next element when peeking.
/// This is useful when you want to peek at the next element without
diff --git a/crates/tantivy/src/collector/filter_collector_wrapper.rs b/crates/tantivy/src/collector/filter_collector_wrapper.rs
index c7b78e4a..9979437f 100644
--- a/crates/tantivy/src/collector/filter_collector_wrapper.rs
+++ b/crates/tantivy/src/collector/filter_collector_wrapper.rs
@@ -142,8 +142,9 @@ where
}
}
-/// A variant of the [`FilterCollector`] specialized for bytes columnar fields, i.e.
-/// it transparently wraps an inner [`Collector`] but filters documents
+/// A variant of the [`FilterCollector`] specialized for bytes columnar fields.
+///
+/// It transparently wraps an inner [`Collector`] but filters documents
/// based on the result of applying the predicate to the bytes columnar field.
///
/// A document is accepted if and only if the predicate returns `true` for at least one value.
diff --git a/crates/tantivy/src/directory/directory_lock.rs b/crates/tantivy/src/directory/directory_lock.rs
index 67a4cada..89c0a3f1 100644
--- a/crates/tantivy/src/directory/directory_lock.rs
+++ b/crates/tantivy/src/directory/directory_lock.rs
@@ -48,6 +48,7 @@ pub static INDEX_WRITER_LOCK: LazyLock<Lock> = LazyLock::new(|| Lock {
});
/// The meta lock file is here to protect the segment files being opened by
/// `IndexReader::reload()` from being garbage collected.
+///
/// It makes it possible for another process to safely consume
/// our index in-writing. Ideally, we may have preferred `RWLock` semantics
/// here, but it is difficult to achieve on Windows.
diff --git a/crates/tantivy/src/index/segment_component.rs b/crates/tantivy/src/index/segment_component.rs
index e39e48af..4378de56 100644
--- a/crates/tantivy/src/index/segment_component.rs
+++ b/crates/tantivy/src/index/segment_component.rs
@@ -1,6 +1,7 @@
use std::slice;
/// Enum describing each component of a tantivy segment.
+///
/// Each component is stored in its own file,
/// using the pattern `segment_uuid`.`component_extension`,
/// except the delete component that takes an `segment_uuid`.`delete_opstamp`.`component_extension`
diff --git a/crates/tantivy/src/positions/mod.rs b/crates/tantivy/src/positions/mod.rs
index cd98eb69..2f2ff318 100644
--- a/crates/tantivy/src/positions/mod.rs
+++ b/crates/tantivy/src/positions/mod.rs
@@ -1,4 +1,5 @@
//! Tantivy can (if instructed to do so in the schema) store the term positions in a given field.
+//!
//! This position is expressed as token ordinal. For instance,
//! In "The beauty and the beast", the term "the" appears in position 0 and position 3.
//! This information is useful to run phrase queries.
diff --git a/crates/tantivy/src/query/grammar/infallible.rs b/crates/tantivy/src/query/grammar/infallible.rs
index 0bc0fb8b..043b42e1 100644
--- a/crates/tantivy/src/query/grammar/infallible.rs
+++ b/crates/tantivy/src/query/grammar/infallible.rs
@@ -113,7 +113,6 @@ where
move |input: I| match f.parse(input) {
Ok((input, (output, _err))) => Ok((input, output)),
Err(Err::Incomplete(needed)) => Err(Err::Incomplete(needed)),
- Err(Err::Error(val)) | Err(Err::Failure(val)) => match val {},
}
}
diff --git a/crates/tantivy/src/query/phrase_prefix_query/phrase_prefix_scorer.rs b/crates/tantivy/src/query/phrase_prefix_query/phrase_prefix_scorer.rs
index 4e76d492..ccb0e080 100644
--- a/crates/tantivy/src/query/phrase_prefix_query/phrase_prefix_scorer.rs
+++ b/crates/tantivy/src/query/phrase_prefix_query/phrase_prefix_scorer.rs
@@ -12,7 +12,7 @@ enum PhraseKind<TPostings: Postings> {
postings: TPostings,
positions: Vec<u32>,
},
- MultiPrefix(PhraseScorer<TPostings>),
+ MultiPrefix(Box<PhraseScorer<TPostings>>),
}
impl<TPostings: Postings> PhraseKind<TPostings> {
@@ -117,13 +117,13 @@ impl<TPostings: Postings> PhrasePrefixScorer<TPostings> {
.unwrap();
let phrase_scorer = if term_postings.len() > 1 {
- PhraseKind::MultiPrefix(PhraseScorer::new_with_offset(
+ PhraseKind::MultiPrefix(Box::new(PhraseScorer::new_with_offset(
term_postings,
similarity_weight_opt,
fieldnorm_reader,
0,
1,
- ))
+ )))
} else {
let (pos, postings) = term_postings
.pop()
diff --git a/crates/tantivy/src/schema/term.rs b/crates/tantivy/src/schema/term.rs
index 07a89600..ceecd51d 100644
--- a/crates/tantivy/src/schema/term.rs
+++ b/crates/tantivy/src/schema/term.rs
@@ -302,6 +302,7 @@ where
}
/// ValueBytes represents a serialized value.
+///
/// The value can be of any type of [`Type`] (e.g. string, u64, f64, bool, date, JSON).
/// The serialized representation matches the lexographical order of the type.
///
diff --git a/crates/tantivy/src/snippet/mod.rs b/crates/tantivy/src/snippet/mod.rs
index 38059a1a..20c0e395 100644
--- a/crates/tantivy/src/snippet/mod.rs
+++ b/crates/tantivy/src/snippet/mod.rs
@@ -1,5 +1,6 @@
//! [`SnippetGenerator`]
//! Generates a text snippet for a given document, and some highlighted parts inside it.
+//!
//! Imagine you doing a text search in a document
//! and want to show a preview of where in the document the search terms occur,
//! along with some surrounding text to give context, and the search terms highlighted.
diff --git a/crates/tantivy/src/tokenizer/regex_tokenizer.rs b/crates/tantivy/src/tokenizer/regex_tokenizer.rs
index f4a608b3..a771e42d 100644
--- a/crates/tantivy/src/tokenizer/regex_tokenizer.rs
+++ b/crates/tantivy/src/tokenizer/regex_tokenizer.rs
@@ -4,6 +4,7 @@ use super::{Token, TokenStream, Tokenizer};
use crate::TantivyError;
/// Tokenize the text by using a regex pattern to split.
+///
/// Each match of the regex emits a distinct token, empty tokens will not be emitted. Anchors such
/// as `\A` will match the text from the part where the last token was emitted or the beginning of
/// the complete text if no token was emitted yet.