mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-29 22:43:09 +08:00
no id returned; fix #492
This commit is contained in:
parent
54c675e195
commit
041eed2a06
@ -1,4 +1,5 @@
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
use assert_json_diff::assert_json_eq;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
@ -467,3 +468,33 @@ fn create_index_failed() {
|
|||||||
assert_eq!(res_value.as_object().unwrap().len(), 1);
|
assert_eq!(res_value.as_object().unwrap().len(), 1);
|
||||||
assert_eq!(message, "invalid data");
|
assert_eq!(message, "invalid data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn create_index_with_identifier() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
|
||||||
|
let body = json!({
|
||||||
|
"uid": "movies",
|
||||||
|
"identifier": "id",
|
||||||
|
});
|
||||||
|
|
||||||
|
let (_response, status_code) = server.create_index(body);
|
||||||
|
assert_eq!(status_code, 201);
|
||||||
|
|
||||||
|
let body = json!([{
|
||||||
|
"id": 123,
|
||||||
|
"text": "The mask"
|
||||||
|
}]);
|
||||||
|
|
||||||
|
server.add_or_replace_multiple_documents(body.clone());
|
||||||
|
|
||||||
|
let (response, _status_code) = server.get_document(123);
|
||||||
|
|
||||||
|
let expect = json!({
|
||||||
|
"id": 123,
|
||||||
|
"text": "The mask"
|
||||||
|
});
|
||||||
|
|
||||||
|
assert_json_eq!(response, expect, ordered: false);
|
||||||
|
}
|
||||||
|
@ -21,13 +21,21 @@ impl Schema {
|
|||||||
let mut fields_map = FieldsMap::default();
|
let mut fields_map = FieldsMap::default();
|
||||||
let field_id = fields_map.insert(name).unwrap();
|
let field_id = fields_map.insert(name).unwrap();
|
||||||
|
|
||||||
|
let mut displayed = HashSet::new();
|
||||||
|
let mut indexed = Vec::new();
|
||||||
|
let mut indexed_map = HashMap::new();
|
||||||
|
|
||||||
|
displayed.insert(field_id);
|
||||||
|
indexed.push(field_id);
|
||||||
|
indexed_map.insert(field_id, 0.into());
|
||||||
|
|
||||||
Schema {
|
Schema {
|
||||||
fields_map,
|
fields_map,
|
||||||
identifier: field_id,
|
identifier: field_id,
|
||||||
ranked: HashSet::new(),
|
ranked: HashSet::new(),
|
||||||
displayed: HashSet::new(),
|
displayed,
|
||||||
indexed: Vec::new(),
|
indexed,
|
||||||
indexed_map: HashMap::new(),
|
indexed_map,
|
||||||
accept_new_fields: true,
|
accept_new_fields: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user