pub struct SearchIndex {
pub docnames: Vec<String>,
pub filenames: Vec<String>,
pub titles: Vec<String>,
pub terms: HashMap<String, Vec<DocumentMatch>>,
pub objects: HashMap<String, ObjectReference>,
pub objnames: HashMap<String, String>,
pub objtypes: HashMap<String, String>,
pub language: String,
}Expand description
Search index that mirrors Sphinx’s search functionality
Fields§
§docnames: Vec<String>§filenames: Vec<String>§titles: Vec<String>§terms: HashMap<String, Vec<DocumentMatch>>§objects: HashMap<String, ObjectReference>§objnames: HashMap<String, String>§objtypes: HashMap<String, String>§language: StringImplementations§
Source§impl SearchIndex
impl SearchIndex
pub fn new(language: String) -> Self
Sourcepub fn add_document(
&mut self,
docname: String,
filename: String,
title: String,
content: &str,
) -> Result<()>
pub fn add_document( &mut self, docname: String, filename: String, title: String, content: &str, ) -> Result<()>
Add a document to the search index
Sourcepub fn add_object(
&mut self,
name: String,
docname: &str,
anchor: Option<String>,
obj_type: &str,
description: Option<String>,
) -> Result<()>
pub fn add_object( &mut self, name: String, docname: &str, anchor: Option<String>, obj_type: &str, description: Option<String>, ) -> Result<()>
Add an object to the search index
Sourcepub fn search(&self, query: &str) -> Vec<SearchResult>
pub fn search(&self, query: &str) -> Vec<SearchResult>
Search for documents matching a query
Trait Implementations§
Source§impl Clone for SearchIndex
impl Clone for SearchIndex
Source§fn clone(&self) -> SearchIndex
fn clone(&self) -> SearchIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SearchIndex
impl Debug for SearchIndex
Source§impl Default for SearchIndex
impl Default for SearchIndex
Source§fn default() -> SearchIndex
fn default() -> SearchIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SearchIndex
impl RefUnwindSafe for SearchIndex
impl Send for SearchIndex
impl Sync for SearchIndex
impl Unpin for SearchIndex
impl UnwindSafe for SearchIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more