mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
Rename AttributesToSearchIn into SearchableAttributes; fix #428
This commit is contained in:
parent
110adcae85
commit
73918d803c
@ -77,7 +77,7 @@ impl IndexSearchExt for Index {
|
|||||||
limit: 20,
|
limit: 20,
|
||||||
attributes_to_crop: None,
|
attributes_to_crop: None,
|
||||||
attributes_to_retrieve: None,
|
attributes_to_retrieve: None,
|
||||||
attributes_to_search_in: None,
|
searchable_attributes: None,
|
||||||
attributes_to_highlight: None,
|
attributes_to_highlight: None,
|
||||||
filters: None,
|
filters: None,
|
||||||
timeout: Duration::from_millis(30),
|
timeout: Duration::from_millis(30),
|
||||||
@ -93,7 +93,7 @@ pub struct SearchBuilder<'a> {
|
|||||||
limit: usize,
|
limit: usize,
|
||||||
attributes_to_crop: Option<HashMap<String, usize>>,
|
attributes_to_crop: Option<HashMap<String, usize>>,
|
||||||
attributes_to_retrieve: Option<HashSet<String>>,
|
attributes_to_retrieve: Option<HashSet<String>>,
|
||||||
attributes_to_search_in: Option<HashSet<String>>,
|
searchable_attributes: Option<HashSet<String>>,
|
||||||
attributes_to_highlight: Option<HashSet<String>>,
|
attributes_to_highlight: Option<HashSet<String>>,
|
||||||
filters: Option<String>,
|
filters: Option<String>,
|
||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
@ -127,14 +127,14 @@ impl<'a> SearchBuilder<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn attributes_to_search_in(&mut self, value: HashSet<String>) -> &SearchBuilder {
|
pub fn searchable_attributes(&mut self, value: HashSet<String>) -> &SearchBuilder {
|
||||||
self.attributes_to_search_in = Some(value);
|
self.searchable_attributes = Some(value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_attribute_to_search_in(&mut self, value: String) -> &SearchBuilder {
|
pub fn add_attribute_to_search_in(&mut self, value: String) -> &SearchBuilder {
|
||||||
let attributes_to_search_in = self.attributes_to_search_in.get_or_insert(HashSet::new());
|
let searchable_attributes = self.searchable_attributes.get_or_insert(HashSet::new());
|
||||||
attributes_to_search_in.insert(value);
|
searchable_attributes.insert(value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ impl<'a> SearchBuilder<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Filter searchable fields
|
// Filter searchable fields
|
||||||
if let Some(fields) = &self.attributes_to_search_in {
|
if let Some(fields) = &self.searchable_attributes {
|
||||||
for attribute in fields.iter().filter_map(|f| schema.attribute(f)) {
|
for attribute in fields.iter().filter_map(|f| schema.attribute(f)) {
|
||||||
query_builder.add_searchable_attribute(attribute.0);
|
query_builder.add_searchable_attribute(attribute.0);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ struct SearchQuery {
|
|||||||
offset: Option<usize>,
|
offset: Option<usize>,
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
attributes_to_retrieve: Option<String>,
|
attributes_to_retrieve: Option<String>,
|
||||||
attributes_to_search_in: Option<String>,
|
searchable_attributes: Option<String>,
|
||||||
attributes_to_crop: Option<String>,
|
attributes_to_crop: Option<String>,
|
||||||
crop_length: Option<usize>,
|
crop_length: Option<usize>,
|
||||||
attributes_to_highlight: Option<String>,
|
attributes_to_highlight: Option<String>,
|
||||||
@ -60,8 +60,8 @@ pub async fn search_with_url_query(ctx: Context<Data>) -> SResult<Response> {
|
|||||||
search_builder.add_retrievable_field(attr.to_string());
|
search_builder.add_retrievable_field(attr.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(attributes_to_search_in) = query.attributes_to_search_in {
|
if let Some(searchable_attributes) = query.searchable_attributes {
|
||||||
for attr in attributes_to_search_in.split(',') {
|
for attr in searchable_attributes.split(',') {
|
||||||
search_builder.add_attribute_to_search_in(attr.to_string());
|
search_builder.add_attribute_to_search_in(attr.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ struct SearchMultiBody {
|
|||||||
offset: Option<usize>,
|
offset: Option<usize>,
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
attributes_to_retrieve: Option<HashSet<String>>,
|
attributes_to_retrieve: Option<HashSet<String>>,
|
||||||
attributes_to_search_in: Option<HashSet<String>>,
|
searchable_attributes: Option<HashSet<String>>,
|
||||||
attributes_to_crop: Option<HashMap<String, usize>>,
|
attributes_to_crop: Option<HashMap<String, usize>>,
|
||||||
attributes_to_highlight: Option<HashSet<String>>,
|
attributes_to_highlight: Option<HashSet<String>>,
|
||||||
filters: Option<String>,
|
filters: Option<String>,
|
||||||
@ -189,8 +189,8 @@ pub async fn search_multi_index(mut ctx: Context<Data>) -> SResult<Response> {
|
|||||||
if let Some(attributes_to_retrieve) = par_body.attributes_to_retrieve.clone() {
|
if let Some(attributes_to_retrieve) = par_body.attributes_to_retrieve.clone() {
|
||||||
search_builder.attributes_to_retrieve(attributes_to_retrieve);
|
search_builder.attributes_to_retrieve(attributes_to_retrieve);
|
||||||
}
|
}
|
||||||
if let Some(attributes_to_search_in) = par_body.attributes_to_search_in.clone() {
|
if let Some(searchable_attributes) = par_body.searchable_attributes.clone() {
|
||||||
search_builder.attributes_to_search_in(attributes_to_search_in);
|
search_builder.searchable_attributes(searchable_attributes);
|
||||||
}
|
}
|
||||||
if let Some(attributes_to_crop) = par_body.attributes_to_crop.clone() {
|
if let Some(attributes_to_crop) = par_body.attributes_to_crop.clone() {
|
||||||
search_builder.attributes_to_crop(attributes_to_crop);
|
search_builder.attributes_to_crop(attributes_to_crop);
|
||||||
|
Loading…
Reference in New Issue
Block a user