mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-26 22:50:07 +01:00
move identifier from settings to index; fix #470
This commit is contained in:
parent
dc9ca2ebc9
commit
4986adc186
@ -357,7 +357,7 @@ mod tests {
|
||||
|
||||
use crate::criterion::{self, CriteriaBuilder};
|
||||
use crate::update::{ProcessedUpdateResult, UpdateStatus};
|
||||
use crate::settings::Settings;
|
||||
use crate::settings::{Settings, SettingsUpdate, UpdateState};
|
||||
use crate::{Document, DocumentId};
|
||||
use serde::de::IgnoredAny;
|
||||
use std::sync::mpsc;
|
||||
@ -377,10 +377,21 @@ mod tests {
|
||||
|
||||
database.set_update_callback(Box::new(update_fn));
|
||||
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update("id".to_string()),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
||||
let mut writer = db.update_write_txn().unwrap();
|
||||
let update_id = index.settings_update(&mut writer, settings_update).unwrap();
|
||||
writer.commit().unwrap();
|
||||
|
||||
// block until the transaction is processed
|
||||
let _ = receiver.iter().find(|id| *id == update_id);
|
||||
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "description"],
|
||||
"displayedAttributes": ["name", "description"]
|
||||
}
|
||||
@ -437,10 +448,21 @@ mod tests {
|
||||
|
||||
database.set_update_callback(Box::new(update_fn));
|
||||
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update("id".to_string()),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
||||
let mut writer = db.update_write_txn().unwrap();
|
||||
let update_id = index.settings_update(&mut writer, settings_update).unwrap();
|
||||
writer.commit().unwrap();
|
||||
|
||||
// block until the transaction is processed
|
||||
let _ = receiver.iter().find(|id| *id == update_id);
|
||||
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "description"],
|
||||
"displayedAttributes": ["name", "description"]
|
||||
}
|
||||
@ -496,10 +518,21 @@ mod tests {
|
||||
|
||||
database.set_update_callback(Box::new(update_fn));
|
||||
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update("id".to_string()),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
||||
let mut writer = db.update_write_txn().unwrap();
|
||||
let update_id = index.settings_update(&mut writer, settings_update).unwrap();
|
||||
writer.commit().unwrap();
|
||||
|
||||
// block until the transaction is processed
|
||||
let _ = receiver.iter().find(|id| *id == update_id);
|
||||
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name"],
|
||||
"displayedAttributes": ["name"]
|
||||
}
|
||||
@ -548,10 +581,21 @@ mod tests {
|
||||
|
||||
database.set_update_callback(Box::new(update_fn));
|
||||
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update("id".to_string()),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
||||
let mut writer = db.update_write_txn().unwrap();
|
||||
let update_id = index.settings_update(&mut writer, settings_update).unwrap();
|
||||
writer.commit().unwrap();
|
||||
|
||||
// block until the transaction is processed
|
||||
let _ = receiver.iter().find(|id| *id == update_id);
|
||||
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "description"],
|
||||
"displayedAttributes": ["name", "description"]
|
||||
}
|
||||
@ -588,7 +632,6 @@ mod tests {
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "description", "age", "sex"],
|
||||
"displayedAttributes": ["name", "description", "age", "sex"]
|
||||
}
|
||||
@ -655,7 +698,6 @@ mod tests {
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "description", "city", "age", "sex"],
|
||||
"displayedAttributes": ["name", "description", "city", "age", "sex"]
|
||||
}
|
||||
@ -691,10 +733,21 @@ mod tests {
|
||||
|
||||
database.set_update_callback(Box::new(update_fn));
|
||||
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update("id".to_string()),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
||||
let mut writer = db.update_write_txn().unwrap();
|
||||
let update_id = index.settings_update(&mut writer, settings_update).unwrap();
|
||||
writer.commit().unwrap();
|
||||
|
||||
// block until the transaction is processed
|
||||
let _ = receiver.iter().find(|id| *id == update_id);
|
||||
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "description"],
|
||||
"displayedAttributes": ["name", "description"]
|
||||
}
|
||||
@ -768,10 +821,21 @@ mod tests {
|
||||
|
||||
database.set_update_callback(Box::new(update_fn));
|
||||
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update("id".to_string()),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
||||
let mut writer = db.update_write_txn().unwrap();
|
||||
let update_id = index.settings_update(&mut writer, settings_update).unwrap();
|
||||
writer.commit().unwrap();
|
||||
|
||||
// block until the transaction is processed
|
||||
let _ = receiver.iter().find(|id| *id == update_id);
|
||||
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "description"],
|
||||
"displayedAttributes": ["name", "description", "id"]
|
||||
}
|
||||
@ -904,10 +968,21 @@ mod tests {
|
||||
|
||||
database.set_update_callback(Box::new(update_fn));
|
||||
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update("id".to_string()),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
||||
let mut writer = db.update_write_txn().unwrap();
|
||||
let update_id = index.settings_update(&mut writer, settings_update).unwrap();
|
||||
writer.commit().unwrap();
|
||||
|
||||
// block until the transaction is processed
|
||||
let _ = receiver.iter().find(|id| *id == update_id);
|
||||
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "description"],
|
||||
"displayedAttributes": ["name", "description"]
|
||||
}
|
||||
@ -968,6 +1043,18 @@ mod tests {
|
||||
|
||||
database.set_update_callback(Box::new(update_fn));
|
||||
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update("id".to_string()),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
||||
let mut writer = db.update_write_txn().unwrap();
|
||||
let update_id = index.settings_update(&mut writer, settings_update).unwrap();
|
||||
writer.commit().unwrap();
|
||||
|
||||
// block until the transaction is processed
|
||||
let _ = receiver.iter().find(|id| *id == update_id);
|
||||
|
||||
let settings = {
|
||||
let data = r#"
|
||||
{
|
||||
@ -980,7 +1067,6 @@ mod tests {
|
||||
"_exact",
|
||||
"dsc(release_date)"
|
||||
],
|
||||
"identifier": "id",
|
||||
"searchableAttributes": ["name", "release_date"],
|
||||
"displayedAttributes": ["name", "release_date"]
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ pub fn apply_settings_update(
|
||||
must_reindex = true;
|
||||
},
|
||||
UpdateState::Nothing => (),
|
||||
};
|
||||
}
|
||||
match settings.displayed_attributes.clone() {
|
||||
UpdateState::Update(v) => schema.update_displayed(v)?,
|
||||
UpdateState::Clear => {
|
||||
@ -97,11 +97,6 @@ pub fn apply_settings_update(
|
||||
schema.update_displayed(clear)?;
|
||||
},
|
||||
UpdateState::Nothing => (),
|
||||
};
|
||||
|
||||
if let UpdateState::Update(v) = settings.identifier.clone() {
|
||||
schema.set_identifier(v.as_ref())?;
|
||||
must_reindex = true;
|
||||
}
|
||||
|
||||
index.main.put_schema(writer, &schema)?;
|
||||
@ -130,9 +125,6 @@ pub fn apply_settings_update(
|
||||
reindex_all_documents(writer, index)?;
|
||||
}
|
||||
|
||||
if let UpdateState::Clear = settings.identifier {
|
||||
index.main.delete_schema(writer)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use meilisearch_core::settings::Settings;
|
||||
use meilisearch_core::settings::{SettingsUpdate, UpdateState};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use tide::{Request, Response};
|
||||
@ -145,11 +145,11 @@ async fn update_multiple_documents(mut ctx: Request<Data>, is_partial: bool) ->
|
||||
None => return Err(ResponseError::bad_request("Could not infer a schema")),
|
||||
},
|
||||
};
|
||||
let settings = Settings {
|
||||
identifier: Some(Some(id)),
|
||||
..Settings::default()
|
||||
let settings_update = SettingsUpdate{
|
||||
identifier: UpdateState::Update(id),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
index.settings_update(&mut update_writer, settings.into_update()?)?;
|
||||
index.settings_update(&mut update_writer, settings_update)?;
|
||||
}
|
||||
|
||||
let mut document_addition = if is_partial {
|
||||
|
@ -40,11 +40,17 @@ pub async fn list_indexes(ctx: Request<Data>) -> SResult<Response> {
|
||||
let created_at = index.main.created_at(&reader)?.into_internal_error()?;
|
||||
let updated_at = index.main.updated_at(&reader)?.into_internal_error()?;
|
||||
|
||||
let identifier = match index.main.schema(&reader) {
|
||||
Ok(Some(schema)) => Some(schema.identifier().to_owned()),
|
||||
_ => None
|
||||
};
|
||||
|
||||
let index_response = IndexResponse {
|
||||
name,
|
||||
uid: index_uid,
|
||||
created_at,
|
||||
updated_at,
|
||||
identifier,
|
||||
};
|
||||
response_body.push(index_response);
|
||||
}
|
||||
@ -65,6 +71,7 @@ struct IndexResponse {
|
||||
uid: String,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
identifier: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn get_index(ctx: Request<Data>) -> SResult<Response> {
|
||||
@ -80,11 +87,17 @@ pub async fn get_index(ctx: Request<Data>) -> SResult<Response> {
|
||||
let created_at = index.main.created_at(&reader)?.into_internal_error()?;
|
||||
let updated_at = index.main.updated_at(&reader)?.into_internal_error()?;
|
||||
|
||||
let identifier = match index.main.schema(&reader) {
|
||||
Ok(Some(schema)) => Some(schema.identifier().to_owned()),
|
||||
_ => None
|
||||
};
|
||||
|
||||
let response_body = IndexResponse {
|
||||
name,
|
||||
uid,
|
||||
created_at,
|
||||
updated_at,
|
||||
identifier
|
||||
};
|
||||
|
||||
Ok(tide::Response::new(200).body_json(&response_body)?)
|
||||
@ -105,6 +118,7 @@ struct IndexCreateResponse {
|
||||
uid: String,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
identifier: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn create_index(mut ctx: Request<Data>) -> SResult<Response> {
|
||||
@ -150,7 +164,7 @@ pub async fn create_index(mut ctx: Request<Data>) -> SResult<Response> {
|
||||
.updated_at(&writer)?
|
||||
.into_internal_error()?;
|
||||
|
||||
if let Some(id) = body.identifier {
|
||||
if let Some(id) = body.identifier.clone() {
|
||||
created_index
|
||||
.main
|
||||
.put_schema(&mut writer, &Schema::with_identifier(&id))?;
|
||||
@ -163,6 +177,7 @@ pub async fn create_index(mut ctx: Request<Data>) -> SResult<Response> {
|
||||
uid,
|
||||
created_at,
|
||||
updated_at,
|
||||
identifier: body.identifier,
|
||||
};
|
||||
|
||||
Ok(tide::Response::new(201).body_json(&response_body)?)
|
||||
@ -171,7 +186,8 @@ pub async fn create_index(mut ctx: Request<Data>) -> SResult<Response> {
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
struct UpdateIndexRequest {
|
||||
name: String,
|
||||
name: Option<String>,
|
||||
identifier: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@ -181,6 +197,7 @@ struct UpdateIndexResponse {
|
||||
uid: String,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
identifier: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn update_index(mut ctx: Request<Data>) -> SResult<Response> {
|
||||
@ -197,21 +214,36 @@ pub async fn update_index(mut ctx: Request<Data>) -> SResult<Response> {
|
||||
let db = &ctx.state().db;
|
||||
let mut writer = db.main_write_txn()?;
|
||||
|
||||
index.main.put_name(&mut writer, &body.name)?;
|
||||
if let Some(name) = body.name {
|
||||
index.main.put_name(&mut writer, &name)?;
|
||||
}
|
||||
|
||||
if let Some(identifier) = body.identifier {
|
||||
if let Ok(Some(_)) = index.main.schema(&writer) {
|
||||
return Err(ResponseError::bad_request("The index identifier cannot be updated"));
|
||||
}
|
||||
index.main.put_schema(&mut writer, &Schema::with_identifier(&identifier))?;
|
||||
}
|
||||
|
||||
index.main.put_updated_at(&mut writer)?;
|
||||
|
||||
writer.commit()?;
|
||||
let reader = db.main_read_txn()?;
|
||||
|
||||
let reader = db.main_read_txn()?;
|
||||
let name = index.main.name(&reader)?.into_internal_error()?;
|
||||
let created_at = index.main.created_at(&reader)?.into_internal_error()?;
|
||||
let updated_at = index.main.updated_at(&reader)?.into_internal_error()?;
|
||||
|
||||
let identifier = match index.main.schema(&reader) {
|
||||
Ok(Some(schema)) => Some(schema.identifier().to_owned()),
|
||||
_ => None
|
||||
};
|
||||
|
||||
let response_body = UpdateIndexResponse {
|
||||
name: body.name,
|
||||
name,
|
||||
uid: index_uid,
|
||||
created_at,
|
||||
updated_at,
|
||||
identifier
|
||||
};
|
||||
|
||||
Ok(tide::Response::new(200).body_json(&response_body)?)
|
||||
|
@ -54,21 +54,36 @@ pub async fn get_all(ctx: Request<Data>) -> SResult<Response> {
|
||||
|
||||
let schema = index.main.schema(&reader)?;
|
||||
|
||||
let identifier = schema.clone().map(|s| s.identifier().to_owned());
|
||||
let searchable_attributes = schema
|
||||
.clone()
|
||||
.map(|s| s.indexed_name().iter().map(|s| (*s).to_string()).collect());
|
||||
let displayed_attributes = schema
|
||||
.clone()
|
||||
.map(|s| s.displayed_name().iter().map(|s| (*s).to_string()).collect());
|
||||
let searchable_attributes = schema.clone().map(|s| {
|
||||
let attrs = s.indexed_name()
|
||||
.iter()
|
||||
.map(|s| (*s).to_string())
|
||||
.collect::<Vec<String>>();
|
||||
if attrs.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(attrs)
|
||||
}
|
||||
});
|
||||
|
||||
let displayed_attributes = schema.clone().map(|s| {
|
||||
let attrs = s.displayed_name()
|
||||
.iter()
|
||||
.map(|s| (*s).to_string())
|
||||
.collect::<HashSet<String>>();
|
||||
if attrs.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(attrs)
|
||||
}
|
||||
});
|
||||
let index_new_fields = schema.map(|s| s.index_new_fields());
|
||||
|
||||
let settings = Settings {
|
||||
ranking_rules: Some(ranking_rules),
|
||||
ranking_distinct: Some(ranking_distinct),
|
||||
identifier: Some(identifier),
|
||||
searchable_attributes: Some(searchable_attributes),
|
||||
displayed_attributes: Some(displayed_attributes),
|
||||
searchable_attributes: searchable_attributes,
|
||||
displayed_attributes: displayed_attributes,
|
||||
stop_words: Some(stop_words),
|
||||
synonyms: Some(synonyms),
|
||||
index_new_fields: Some(index_new_fields),
|
||||
@ -100,7 +115,6 @@ pub async fn update_all(mut ctx: Request<Data>) -> SResult<Response> {
|
||||
let settings = Settings {
|
||||
ranking_rules: Some(settings_update.ranking_rules),
|
||||
ranking_distinct: Some(settings_update.ranking_distinct),
|
||||
identifier: Some(settings_update.identifier),
|
||||
searchable_attributes: Some(settings_update.searchable_attributes),
|
||||
displayed_attributes: Some(settings_update.displayed_attributes),
|
||||
stop_words: Some(settings_update.stop_words),
|
||||
@ -321,8 +335,12 @@ pub async fn displayed(ctx: Request<Data>) -> SResult<Response> {
|
||||
|
||||
let schema = index.main.schema(&reader)?;
|
||||
|
||||
let displayed_attributes: Option<HashSet<String>> =
|
||||
schema.map(|s| s.displayed_name().iter().map(|i| (*i).to_string()).collect());
|
||||
let displayed_attributes: Option<HashSet<String>> = schema.map(|s| {
|
||||
s.displayed_name()
|
||||
.iter()
|
||||
.map(|i| (*i).to_string())
|
||||
.collect()
|
||||
});
|
||||
|
||||
Ok(tide::Response::new(200)
|
||||
.body_json(&displayed_attributes)
|
||||
|
@ -64,7 +64,6 @@ pub fn enrich_server_with_movies_settings(
|
||||
"dsc(vote_average)",
|
||||
],
|
||||
"rankingDistinct": null,
|
||||
"identifier": "id",
|
||||
"searchableAttributes": [
|
||||
"title",
|
||||
"tagline",
|
||||
|
@ -30,7 +30,7 @@ fn create_index_with_name() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res1_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 5);
|
||||
let r1_name = res1_value["name"].as_str().unwrap();
|
||||
let r1_uid = res1_value["uid"].as_str().unwrap();
|
||||
let r1_created_at = res1_value["createdAt"].as_str().unwrap();
|
||||
@ -54,7 +54,7 @@ fn create_index_with_name() {
|
||||
let res2_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res2_value.as_array().unwrap().len(), 1);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 5);
|
||||
let r2_name = res2_value[0]["name"].as_str().unwrap();
|
||||
let r2_uid = res2_value[0]["uid"].as_str().unwrap();
|
||||
let r2_created_at = res2_value[0]["createdAt"].as_str().unwrap();
|
||||
@ -90,7 +90,7 @@ fn create_index_with_uid() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res1_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 5);
|
||||
let r1_name = res1_value["name"].as_str().unwrap();
|
||||
let r1_uid = res1_value["uid"].as_str().unwrap();
|
||||
let r1_created_at = res1_value["createdAt"].as_str().unwrap();
|
||||
@ -114,7 +114,7 @@ fn create_index_with_uid() {
|
||||
let res2_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res2_value.as_array().unwrap().len(), 1);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 5);
|
||||
let r2_name = res2_value[0]["name"].as_str().unwrap();
|
||||
let r2_uid = res2_value[0]["uid"].as_str().unwrap();
|
||||
let r2_created_at = res2_value[0]["createdAt"].as_str().unwrap();
|
||||
@ -151,7 +151,7 @@ fn create_index_with_name_and_uid() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res1_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 5);
|
||||
let r1_name = res1_value["name"].as_str().unwrap();
|
||||
let r1_uid = res1_value["uid"].as_str().unwrap();
|
||||
let r1_created_at = res1_value["createdAt"].as_str().unwrap();
|
||||
@ -175,7 +175,7 @@ fn create_index_with_name_and_uid() {
|
||||
let res2_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res2_value.as_array().unwrap().len(), 1);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 5);
|
||||
let r2_name = res2_value[0]["name"].as_str().unwrap();
|
||||
let r2_uid = res2_value[0]["uid"].as_str().unwrap();
|
||||
let r2_created_at = res2_value[0]["createdAt"].as_str().unwrap();
|
||||
@ -210,7 +210,7 @@ fn rename_index() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res1_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 5);
|
||||
let r1_name = res1_value["name"].as_str().unwrap();
|
||||
let r1_uid = res1_value["uid"].as_str().unwrap();
|
||||
let r1_created_at = res1_value["createdAt"].as_str().unwrap();
|
||||
@ -241,7 +241,7 @@ fn rename_index() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res2_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res2_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res2_value.as_object().unwrap().len(), 5);
|
||||
let r2_name = res2_value["name"].as_str().unwrap();
|
||||
let r2_uid = res2_value["uid"].as_str().unwrap();
|
||||
let r2_created_at = res2_value["createdAt"].as_str().unwrap();
|
||||
@ -265,7 +265,7 @@ fn rename_index() {
|
||||
let res3_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res3_value.as_array().unwrap().len(), 1);
|
||||
assert_eq!(res3_value[0].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res3_value[0].as_object().unwrap().len(), 5);
|
||||
let r3_name = res3_value[0]["name"].as_str().unwrap();
|
||||
let r3_uid = res3_value[0]["uid"].as_str().unwrap();
|
||||
let r3_created_at = res3_value[0]["createdAt"].as_str().unwrap();
|
||||
@ -301,7 +301,7 @@ fn delete_index_and_recreate_it() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res1_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 5);
|
||||
let r1_name = res1_value["name"].as_str().unwrap();
|
||||
let r1_uid = res1_value["uid"].as_str().unwrap();
|
||||
let r1_created_at = res1_value["createdAt"].as_str().unwrap();
|
||||
@ -325,7 +325,7 @@ fn delete_index_and_recreate_it() {
|
||||
let res2_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res2_value.as_array().unwrap().len(), 1);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 5);
|
||||
let r2_name = res2_value[0]["name"].as_str().unwrap();
|
||||
let r2_uid = res2_value[0]["uid"].as_str().unwrap();
|
||||
let r2_created_at = res2_value[0]["createdAt"].as_str().unwrap();
|
||||
@ -384,7 +384,7 @@ fn delete_index_and_recreate_it() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res1_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 5);
|
||||
let r1_name = res1_value["name"].as_str().unwrap();
|
||||
let r1_uid = res1_value["uid"].as_str().unwrap();
|
||||
let r1_created_at = res1_value["createdAt"].as_str().unwrap();
|
||||
@ -408,7 +408,7 @@ fn delete_index_and_recreate_it() {
|
||||
let res2_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res2_value.as_array().unwrap().len(), 1);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 5);
|
||||
let r2_name = res2_value[0]["name"].as_str().unwrap();
|
||||
let r2_uid = res2_value[0]["uid"].as_str().unwrap();
|
||||
let r2_created_at = res2_value[0]["createdAt"].as_str().unwrap();
|
||||
@ -444,7 +444,7 @@ fn check_multiples_indexes() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res1_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res1_value.as_object().unwrap().len(), 5);
|
||||
let r1_name = res1_value["name"].as_str().unwrap();
|
||||
let r1_uid = res1_value["uid"].as_str().unwrap();
|
||||
let r1_created_at = res1_value["createdAt"].as_str().unwrap();
|
||||
@ -468,7 +468,7 @@ fn check_multiples_indexes() {
|
||||
let res2_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res2_value.as_array().unwrap().len(), 1);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res2_value[0].as_object().unwrap().len(), 5);
|
||||
let r2_0_name = res2_value[0]["name"].as_str().unwrap();
|
||||
let r2_0_uid = res2_value[0]["uid"].as_str().unwrap();
|
||||
let r2_0_created_at = res2_value[0]["createdAt"].as_str().unwrap();
|
||||
@ -499,7 +499,7 @@ fn check_multiples_indexes() {
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let res3_value: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert_eq!(res3_value.as_object().unwrap().len(), 4);
|
||||
assert_eq!(res3_value.as_object().unwrap().len(), 5);
|
||||
let r3_name = res3_value["name"].as_str().unwrap();
|
||||
let r3_uid = res3_value["uid"].as_str().unwrap();
|
||||
let r3_created_at = res3_value["createdAt"].as_str().unwrap();
|
||||
@ -524,13 +524,13 @@ fn check_multiples_indexes() {
|
||||
|
||||
assert_eq!(res4_value.as_array().unwrap().len(), 2);
|
||||
|
||||
assert_eq!(res4_value[0].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res4_value[0].as_object().unwrap().len(), 5);
|
||||
let r4_0_name = res4_value[0]["name"].as_str().unwrap();
|
||||
let r4_0_uid = res4_value[0]["uid"].as_str().unwrap();
|
||||
let r4_0_created_at = res4_value[0]["createdAt"].as_str().unwrap();
|
||||
let r4_0_updated_at = res4_value[0]["updatedAt"].as_str().unwrap();
|
||||
|
||||
assert_eq!(res4_value[1].as_object().unwrap().len(), 4);
|
||||
assert_eq!(res4_value[1].as_object().unwrap().len(), 5);
|
||||
let r4_1_name = res4_value[1]["name"].as_str().unwrap();
|
||||
let r4_1_uid = res4_value[1]["uid"].as_str().unwrap();
|
||||
let r4_1_created_at = res4_value[1]["createdAt"].as_str().unwrap();
|
||||
|
@ -26,6 +26,7 @@ fn write_all_and_delete() {
|
||||
|
||||
let body = json!({
|
||||
"uid": "movies",
|
||||
"identifier": "id",
|
||||
})
|
||||
.to_string()
|
||||
.into_bytes();
|
||||
@ -50,7 +51,6 @@ fn write_all_and_delete() {
|
||||
"dsc(rank)",
|
||||
],
|
||||
"rankingDistinct": "movie_id",
|
||||
"identifier": "id",
|
||||
"searchableAttributes": [
|
||||
"id",
|
||||
"movie_id",
|
||||
@ -128,12 +128,11 @@ fn write_all_and_delete() {
|
||||
let json = json!({
|
||||
"rankingRules": null,
|
||||
"rankingDistinct": null,
|
||||
"identifier": null,
|
||||
"searchableAttributes": null,
|
||||
"displayedAttributes": null,
|
||||
"stopWords": null,
|
||||
"synonyms": null,
|
||||
"indexNewFields": null,
|
||||
"indexNewFields": true,
|
||||
});
|
||||
|
||||
assert_json_eq!(json, res_value, ordered: false);
|
||||
@ -155,6 +154,7 @@ fn write_all_and_update() {
|
||||
|
||||
let body = json!({
|
||||
"uid": "movies",
|
||||
"identifier": "id",
|
||||
})
|
||||
.to_string()
|
||||
.into_bytes();
|
||||
@ -179,7 +179,6 @@ fn write_all_and_update() {
|
||||
"dsc(rank)",
|
||||
],
|
||||
"rankingDistinct": "movie_id",
|
||||
"identifier": "uid",
|
||||
"searchableAttributes": [
|
||||
"uid",
|
||||
"movie_id",
|
||||
@ -244,7 +243,6 @@ fn write_all_and_update() {
|
||||
"_exact",
|
||||
"dsc(release_date)",
|
||||
],
|
||||
"identifier": "uid",
|
||||
"searchableAttributes": [
|
||||
"title",
|
||||
"description",
|
||||
@ -299,7 +297,6 @@ fn write_all_and_update() {
|
||||
"dsc(release_date)",
|
||||
],
|
||||
"rankingDistinct": null,
|
||||
"identifier": "uid",
|
||||
"searchableAttributes": [
|
||||
"title",
|
||||
"description",
|
||||
|
Loading…
x
Reference in New Issue
Block a user