pub struct SearchOptions {
pub top_k: usize,
pub mode: SearchMode,
pub alpha: Option<f32>,
pub filter_languages: Vec<String>,
pub filter_paths: Vec<String>,
pub use_query_cache: bool,
pub explain: bool,
}Fields§
§top_k: usize§mode: SearchMode§alpha: Option<f32>§filter_languages: Vec<String>§filter_paths: Vec<String>§use_query_cache: bool§explain: boolImplementations§
Source§impl SearchOptions
impl SearchOptions
Sourcepub fn new(top_k: usize) -> Self
pub fn new(top_k: usize) -> Self
Examples found in repository?
examples/bench.rs (line 20)
4fn main() -> anyhow::Result<()> {
5 let path = std::env::args().nth(1).unwrap_or_else(|| ".".to_owned());
6 let query = std::env::args()
7 .nth(2)
8 .unwrap_or_else(|| "hybrid search ranking".to_owned());
9 let runs = std::env::args()
10 .nth(3)
11 .and_then(|s| s.parse::<usize>().ok())
12 .unwrap_or(100);
13
14 let start = Instant::now();
15 let index = SifsIndex::from_path(&path)?;
16 let index_ms = start.elapsed().as_secs_f64() * 1000.0;
17
18 let mut uncached_times = Vec::with_capacity(runs);
19 let mut cached_times = Vec::with_capacity(runs);
20 let uncached = SearchOptions::new(10)
21 .with_mode(SearchMode::Hybrid)
22 .with_cache(false);
23 let cached = SearchOptions::new(10)
24 .with_mode(SearchMode::Hybrid)
25 .with_cache(true);
26 std::hint::black_box(index.search_with(&query, &uncached)?);
27 for _ in 0..runs {
28 let start = Instant::now();
29 let results = index.search_with(&query, &uncached)?;
30 std::hint::black_box(results);
31 uncached_times.push(start.elapsed().as_secs_f64() * 1000.0);
32 }
33 std::hint::black_box(index.search_with(&query, &cached)?);
34 for _ in 0..runs {
35 let start = Instant::now();
36 let results = index.search_with(&query, &cached)?;
37 std::hint::black_box(results);
38 cached_times.push(start.elapsed().as_secs_f64() * 1000.0);
39 }
40 uncached_times.sort_by(|a, b| a.partial_cmp(b).unwrap());
41 cached_times.sort_by(|a, b| a.partial_cmp(b).unwrap());
42 let uncached_p50 = uncached_times[uncached_times.len() / 2];
43 let uncached_p90 =
44 uncached_times[(uncached_times.len() * 9 / 10).min(uncached_times.len() - 1)];
45 let cached_p50 = cached_times[cached_times.len() / 2];
46 let cached_p90 = cached_times[(cached_times.len() * 9 / 10).min(cached_times.len() - 1)];
47 let stats = index.stats();
48 println!(
49 "cold_index_ms={index_ms:.3} warm_uncached_query_ms={uncached_p50:.3} warm_uncached_query_p90_ms={uncached_p90:.3} warm_cached_repeat_query_ms={cached_p50:.3} warm_cached_repeat_query_p90_ms={cached_p90:.3} peak_rss_mb={:.1} files={} chunks={}",
50 peak_rss_mb(),
51 stats.indexed_files,
52 index.chunks.len()
53 );
54 Ok(())
55}Sourcepub fn with_mode(self, mode: SearchMode) -> Self
pub fn with_mode(self, mode: SearchMode) -> Self
Examples found in repository?
examples/bench.rs (line 21)
4fn main() -> anyhow::Result<()> {
5 let path = std::env::args().nth(1).unwrap_or_else(|| ".".to_owned());
6 let query = std::env::args()
7 .nth(2)
8 .unwrap_or_else(|| "hybrid search ranking".to_owned());
9 let runs = std::env::args()
10 .nth(3)
11 .and_then(|s| s.parse::<usize>().ok())
12 .unwrap_or(100);
13
14 let start = Instant::now();
15 let index = SifsIndex::from_path(&path)?;
16 let index_ms = start.elapsed().as_secs_f64() * 1000.0;
17
18 let mut uncached_times = Vec::with_capacity(runs);
19 let mut cached_times = Vec::with_capacity(runs);
20 let uncached = SearchOptions::new(10)
21 .with_mode(SearchMode::Hybrid)
22 .with_cache(false);
23 let cached = SearchOptions::new(10)
24 .with_mode(SearchMode::Hybrid)
25 .with_cache(true);
26 std::hint::black_box(index.search_with(&query, &uncached)?);
27 for _ in 0..runs {
28 let start = Instant::now();
29 let results = index.search_with(&query, &uncached)?;
30 std::hint::black_box(results);
31 uncached_times.push(start.elapsed().as_secs_f64() * 1000.0);
32 }
33 std::hint::black_box(index.search_with(&query, &cached)?);
34 for _ in 0..runs {
35 let start = Instant::now();
36 let results = index.search_with(&query, &cached)?;
37 std::hint::black_box(results);
38 cached_times.push(start.elapsed().as_secs_f64() * 1000.0);
39 }
40 uncached_times.sort_by(|a, b| a.partial_cmp(b).unwrap());
41 cached_times.sort_by(|a, b| a.partial_cmp(b).unwrap());
42 let uncached_p50 = uncached_times[uncached_times.len() / 2];
43 let uncached_p90 =
44 uncached_times[(uncached_times.len() * 9 / 10).min(uncached_times.len() - 1)];
45 let cached_p50 = cached_times[cached_times.len() / 2];
46 let cached_p90 = cached_times[(cached_times.len() * 9 / 10).min(cached_times.len() - 1)];
47 let stats = index.stats();
48 println!(
49 "cold_index_ms={index_ms:.3} warm_uncached_query_ms={uncached_p50:.3} warm_uncached_query_p90_ms={uncached_p90:.3} warm_cached_repeat_query_ms={cached_p50:.3} warm_cached_repeat_query_p90_ms={cached_p90:.3} peak_rss_mb={:.1} files={} chunks={}",
50 peak_rss_mb(),
51 stats.indexed_files,
52 index.chunks.len()
53 );
54 Ok(())
55}pub fn with_alpha(self, alpha: f32) -> Self
pub fn with_languages(self, languages: impl IntoIterator<Item = String>) -> Self
pub fn with_paths(self, paths: impl IntoIterator<Item = String>) -> Self
Sourcepub fn with_cache(self, use_query_cache: bool) -> Self
pub fn with_cache(self, use_query_cache: bool) -> Self
Examples found in repository?
examples/bench.rs (line 22)
4fn main() -> anyhow::Result<()> {
5 let path = std::env::args().nth(1).unwrap_or_else(|| ".".to_owned());
6 let query = std::env::args()
7 .nth(2)
8 .unwrap_or_else(|| "hybrid search ranking".to_owned());
9 let runs = std::env::args()
10 .nth(3)
11 .and_then(|s| s.parse::<usize>().ok())
12 .unwrap_or(100);
13
14 let start = Instant::now();
15 let index = SifsIndex::from_path(&path)?;
16 let index_ms = start.elapsed().as_secs_f64() * 1000.0;
17
18 let mut uncached_times = Vec::with_capacity(runs);
19 let mut cached_times = Vec::with_capacity(runs);
20 let uncached = SearchOptions::new(10)
21 .with_mode(SearchMode::Hybrid)
22 .with_cache(false);
23 let cached = SearchOptions::new(10)
24 .with_mode(SearchMode::Hybrid)
25 .with_cache(true);
26 std::hint::black_box(index.search_with(&query, &uncached)?);
27 for _ in 0..runs {
28 let start = Instant::now();
29 let results = index.search_with(&query, &uncached)?;
30 std::hint::black_box(results);
31 uncached_times.push(start.elapsed().as_secs_f64() * 1000.0);
32 }
33 std::hint::black_box(index.search_with(&query, &cached)?);
34 for _ in 0..runs {
35 let start = Instant::now();
36 let results = index.search_with(&query, &cached)?;
37 std::hint::black_box(results);
38 cached_times.push(start.elapsed().as_secs_f64() * 1000.0);
39 }
40 uncached_times.sort_by(|a, b| a.partial_cmp(b).unwrap());
41 cached_times.sort_by(|a, b| a.partial_cmp(b).unwrap());
42 let uncached_p50 = uncached_times[uncached_times.len() / 2];
43 let uncached_p90 =
44 uncached_times[(uncached_times.len() * 9 / 10).min(uncached_times.len() - 1)];
45 let cached_p50 = cached_times[cached_times.len() / 2];
46 let cached_p90 = cached_times[(cached_times.len() * 9 / 10).min(cached_times.len() - 1)];
47 let stats = index.stats();
48 println!(
49 "cold_index_ms={index_ms:.3} warm_uncached_query_ms={uncached_p50:.3} warm_uncached_query_p90_ms={uncached_p90:.3} warm_cached_repeat_query_ms={cached_p50:.3} warm_cached_repeat_query_p90_ms={cached_p90:.3} peak_rss_mb={:.1} files={} chunks={}",
50 peak_rss_mb(),
51 stats.indexed_files,
52 index.chunks.len()
53 );
54 Ok(())
55}pub fn with_explain(self, explain: bool) -> Self
Trait Implementations§
Source§impl Clone for SearchOptions
impl Clone for SearchOptions
Source§fn clone(&self) -> SearchOptions
fn clone(&self) -> SearchOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 SearchOptions
impl Debug for SearchOptions
Source§impl Default for SearchOptions
impl Default for SearchOptions
Source§impl From<SearchOptions> for SearchOptionsWire
impl From<SearchOptions> for SearchOptionsWire
Source§fn from(value: SearchOptions) -> Self
fn from(value: SearchOptions) -> Self
Converts to this type from the input type.
Source§impl From<SearchOptionsWire> for SearchOptions
impl From<SearchOptionsWire> for SearchOptions
Source§fn from(value: SearchOptionsWire) -> Self
fn from(value: SearchOptionsWire) -> Self
Converts to this type from the input type.
Source§impl PartialEq for SearchOptions
impl PartialEq for SearchOptions
Source§fn eq(&self, other: &SearchOptions) -> bool
fn eq(&self, other: &SearchOptions) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SearchOptions
Auto Trait Implementations§
impl Freeze for SearchOptions
impl RefUnwindSafe for SearchOptions
impl Send for SearchOptions
impl Sync for SearchOptions
impl Unpin for SearchOptions
impl UnsafeUnpin for SearchOptions
impl UnwindSafe for SearchOptions
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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