mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-19 01:18:31 +08:00
rename method and variable around the attributes to search on feature
This commit is contained in:
parent
5542f1d9f1
commit
c78a2fa4f5
@ -158,7 +158,7 @@ impl<'a> Search<'a> {
|
|||||||
let mut ctx = SearchContext::new(self.index, self.rtxn)?;
|
let mut ctx = SearchContext::new(self.index, self.rtxn)?;
|
||||||
|
|
||||||
if let Some(searchable_attributes) = self.searchable_attributes {
|
if let Some(searchable_attributes) = self.searchable_attributes {
|
||||||
ctx.searchable_attributes(searchable_attributes)?;
|
ctx.attributes_to_search_on(searchable_attributes)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let universe = filtered_universe(&ctx, &self.filter)?;
|
let universe = filtered_universe(&ctx, &self.filter)?;
|
||||||
|
@ -96,9 +96,12 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn searchable_attributes(&mut self, attributes_to_search_on: &'ctx [String]) -> Result<()> {
|
pub fn attributes_to_search_on(
|
||||||
|
&mut self,
|
||||||
|
attributes_to_search_on: &'ctx [String],
|
||||||
|
) -> Result<()> {
|
||||||
let user_defined_searchable = self.index.user_defined_searchable_fields(self.txn)?;
|
let user_defined_searchable = self.index.user_defined_searchable_fields(self.txn)?;
|
||||||
let searchable_names = self.index.searchable_fields_and_weights(self.txn)?;
|
let searchable_fields_weights = self.index.searchable_fields_and_weights(self.txn)?;
|
||||||
let exact_attributes_ids = self.index.exact_attributes_ids(self.txn)?;
|
let exact_attributes_ids = self.index.exact_attributes_ids(self.txn)?;
|
||||||
|
|
||||||
let mut wildcard = false;
|
let mut wildcard = false;
|
||||||
@ -110,7 +113,8 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
// we cannot early exit as we want to returns error in case of unknown fields
|
// we cannot early exit as we want to returns error in case of unknown fields
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let searchable_weight = searchable_names.iter().find(|(name, _, _)| name == field_name);
|
let searchable_weight =
|
||||||
|
searchable_fields_weights.iter().find(|(name, _, _)| name == field_name);
|
||||||
let (fid, weight) = match searchable_weight {
|
let (fid, weight) = match searchable_weight {
|
||||||
// The Field id exist and the field is searchable
|
// The Field id exist and the field is searchable
|
||||||
Some((_name, fid, weight)) => (*fid, *weight),
|
Some((_name, fid, weight)) => (*fid, *weight),
|
||||||
@ -120,7 +124,7 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
None => {
|
None => {
|
||||||
let (valid_fields, hidden_fields) = self.index.remove_hidden_fields(
|
let (valid_fields, hidden_fields) = self.index.remove_hidden_fields(
|
||||||
self.txn,
|
self.txn,
|
||||||
searchable_names.iter().map(|(name, _, _)| name),
|
searchable_fields_weights.iter().map(|(name, _, _)| name),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let field = field_name.to_string();
|
let field = field_name.to_string();
|
||||||
|
Loading…
Reference in New Issue
Block a user