mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 00:55:00 +08:00
Fix compilation issues
This commit is contained in:
parent
0252cfe8b6
commit
87e22e436a
@ -25,7 +25,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO improve the error messages
|
// TODO improve the error messages
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Eq, deserr::Deserr)]
|
#[derive(Debug, Clone, Default, PartialEq, deserr::Deserr)]
|
||||||
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct FacetSearchQuery {
|
pub struct FacetSearchQuery {
|
||||||
#[deserr(default, error = DeserrJsonError<InvalidFacetSearchQuery>)]
|
#[deserr(default, error = DeserrJsonError<InvalidFacetSearchQuery>)]
|
||||||
@ -34,6 +34,8 @@ pub struct FacetSearchQuery {
|
|||||||
pub facet_name: String,
|
pub facet_name: String,
|
||||||
#[deserr(default, error = DeserrJsonError<InvalidSearchQ>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchQ>)]
|
||||||
pub q: Option<String>,
|
pub q: Option<String>,
|
||||||
|
#[deserr(default, error = DeserrJsonError<InvalidSearchVector>)]
|
||||||
|
pub vector: Option<Vec<f32>>,
|
||||||
#[deserr(default = DEFAULT_SEARCH_OFFSET(), error = DeserrJsonError<InvalidSearchOffset>)]
|
#[deserr(default = DEFAULT_SEARCH_OFFSET(), error = DeserrJsonError<InvalidSearchOffset>)]
|
||||||
pub offset: usize,
|
pub offset: usize,
|
||||||
#[deserr(default = DEFAULT_SEARCH_LIMIT(), error = DeserrJsonError<InvalidSearchLimit>)]
|
#[deserr(default = DEFAULT_SEARCH_LIMIT(), error = DeserrJsonError<InvalidSearchLimit>)]
|
||||||
@ -52,6 +54,10 @@ pub struct FacetSearchQuery {
|
|||||||
pub attributes_to_highlight: Option<HashSet<String>>,
|
pub attributes_to_highlight: Option<HashSet<String>>,
|
||||||
#[deserr(default, error = DeserrJsonError<InvalidSearchShowMatchesPosition>, default)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchShowMatchesPosition>, default)]
|
||||||
pub show_matches_position: bool,
|
pub show_matches_position: bool,
|
||||||
|
#[deserr(default, error = DeserrJsonError<InvalidSearchShowRankingScore>, default)]
|
||||||
|
pub show_ranking_score: bool,
|
||||||
|
#[deserr(default, error = DeserrJsonError<InvalidSearchShowRankingScoreDetails>, default)]
|
||||||
|
pub show_ranking_score_details: bool,
|
||||||
#[deserr(default, error = DeserrJsonError<InvalidSearchFilter>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchFilter>)]
|
||||||
pub filter: Option<Value>,
|
pub filter: Option<Value>,
|
||||||
#[deserr(default, error = DeserrJsonError<InvalidSearchSort>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchSort>)]
|
||||||
@ -92,8 +98,9 @@ pub async fn search(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let index = index_scheduler.index(&index_uid)?;
|
let index = index_scheduler.index(&index_uid)?;
|
||||||
|
let features = index_scheduler.features()?;
|
||||||
let search_result = tokio::task::spawn_blocking(move || {
|
let search_result = tokio::task::spawn_blocking(move || {
|
||||||
perform_facet_search(&index, search_query, facet_query, facet_name)
|
perform_facet_search(&index, search_query, facet_query, facet_name, features)
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@ -121,6 +128,8 @@ impl From<FacetSearchQuery> for SearchQuery {
|
|||||||
crop_length: value.crop_length,
|
crop_length: value.crop_length,
|
||||||
attributes_to_highlight: value.attributes_to_highlight,
|
attributes_to_highlight: value.attributes_to_highlight,
|
||||||
show_matches_position: value.show_matches_position,
|
show_matches_position: value.show_matches_position,
|
||||||
|
show_ranking_score: value.show_ranking_score,
|
||||||
|
show_ranking_score_details: value.show_ranking_score_details,
|
||||||
filter: value.filter,
|
filter: value.filter,
|
||||||
sort: value.sort,
|
sort: value.sort,
|
||||||
facets: value.facets,
|
facets: value.facets,
|
||||||
@ -128,6 +137,7 @@ impl From<FacetSearchQuery> for SearchQuery {
|
|||||||
highlight_post_tag: value.highlight_post_tag,
|
highlight_post_tag: value.highlight_post_tag,
|
||||||
crop_marker: value.crop_marker,
|
crop_marker: value.crop_marker,
|
||||||
matching_strategy: value.matching_strategy,
|
matching_strategy: value.matching_strategy,
|
||||||
|
vector: value.vector,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -585,11 +585,12 @@ pub fn perform_facet_search(
|
|||||||
search_query: SearchQuery,
|
search_query: SearchQuery,
|
||||||
facet_query: Option<String>,
|
facet_query: Option<String>,
|
||||||
facet_name: String,
|
facet_name: String,
|
||||||
|
features: RoFeatures,
|
||||||
) -> Result<FacetSearchResult, MeilisearchHttpError> {
|
) -> Result<FacetSearchResult, MeilisearchHttpError> {
|
||||||
let before_search = Instant::now();
|
let before_search = Instant::now();
|
||||||
let rtxn = index.read_txn()?;
|
let rtxn = index.read_txn()?;
|
||||||
|
|
||||||
let (search, _, _, _) = prepare_search(index, &rtxn, &search_query)?;
|
let (search, _, _, _) = prepare_search(index, &rtxn, &search_query, features)?;
|
||||||
let mut facet_search = SearchForFacetValues::new(facet_name, search);
|
let mut facet_search = SearchForFacetValues::new(facet_name, search);
|
||||||
if let Some(facet_query) = &facet_query {
|
if let Some(facet_query) = &facet_query {
|
||||||
facet_search.query(facet_query);
|
facet_search.query(facet_query);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use fst::automaton::{Complement, Intersection, StartsWith, Str, Union};
|
use fst::automaton::{Automaton, Str};
|
||||||
use fst::Streamer;
|
use fst::{IntoStreamer, Streamer};
|
||||||
use levenshtein_automata::{LevenshteinAutomatonBuilder as LevBuilder, DFA};
|
use levenshtein_automata::{LevenshteinAutomatonBuilder as LevBuilder, DFA};
|
||||||
use log::{debug, error};
|
use log::error;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use roaring::bitmap::RoaringBitmap;
|
use roaring::bitmap::RoaringBitmap;
|
||||||
|
|
||||||
@ -314,12 +314,12 @@ impl<'a> SearchForFacetValues<'a> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let is_prefix = true;
|
let is_prefix = true;
|
||||||
let starts = StartsWith(Str::new(get_first(query)));
|
let starts = Str::new(get_first(query)).starts_with();
|
||||||
let first =
|
let first = build_dfa(query, 1, is_prefix)
|
||||||
Intersection(build_dfa(query, 1, is_prefix), Complement(&starts));
|
.intersection(starts.clone().complement());
|
||||||
let second_dfa = build_dfa(query, 2, is_prefix);
|
let second_dfa = build_dfa(query, 2, is_prefix);
|
||||||
let second = Intersection(&second_dfa, &starts);
|
let second = second_dfa.intersection(starts);
|
||||||
let automaton = Union(first, &second);
|
let automaton = first.union(&second);
|
||||||
|
|
||||||
let mut stream = fst.search(automaton).into_stream();
|
let mut stream = fst.search(automaton).into_stream();
|
||||||
let mut length = 0;
|
let mut length = 0;
|
||||||
@ -348,7 +348,7 @@ impl<'a> SearchForFacetValues<'a> {
|
|||||||
|
|
||||||
Ok(results)
|
Ok(results)
|
||||||
} else {
|
} else {
|
||||||
let automaton = StartsWith(Str::new(query));
|
let automaton = Str::new(query).starts_with();
|
||||||
let mut stream = fst.search(automaton).into_stream();
|
let mut stream = fst.search(automaton).into_stream();
|
||||||
let mut results = vec![];
|
let mut results = vec![];
|
||||||
let mut length = 0;
|
let mut length = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user