mirror of
https://github.com/typesense/typesense.git
synced 2025-05-18 20:52:50 +08:00
Fix inheritance of sort field property for nested field.
This commit is contained in:
parent
54492fafdc
commit
da8cac463c
@ -505,7 +505,9 @@ bool field::flatten_obj(nlohmann::json& doc, nlohmann::json& value, bool has_arr
|
||||
flattened_field.optional = true;
|
||||
flattened_field.nested = true;
|
||||
flattened_field.nested_array = has_obj_array;
|
||||
flattened_field.set_computed_defaults(-1, -1);
|
||||
int sort_op = flattened_field.sort ? 1 : -1;
|
||||
int infix_op = flattened_field.infix ? 1 : -1;
|
||||
flattened_field.set_computed_defaults(sort_op, infix_op);
|
||||
flattened_fields[flat_name] = flattened_field;
|
||||
}
|
||||
|
||||
|
@ -3360,3 +3360,29 @@ TEST_F(CollectionNestedFieldsTest, HighlightOnFlatFieldWithSnippeting) {
|
||||
|
||||
ASSERT_EQ(highlight_doc.dump(), results["hits"][0]["highlight"].dump());
|
||||
}
|
||||
|
||||
TEST_F(CollectionNestedFieldsTest, NestedObjecEnableSortOnString) {
|
||||
nlohmann::json schema = R"({
|
||||
"name": "coll1",
|
||||
"enable_nested_fields": true,
|
||||
"fields": [
|
||||
{"name": "status", "type": "object"},
|
||||
{"name": "status\\..*", "type": "string", "sort": true}
|
||||
]
|
||||
})"_json;
|
||||
|
||||
auto op = collectionManager.create_collection(schema);
|
||||
ASSERT_TRUE(op.ok());
|
||||
Collection* coll1 = op.get();
|
||||
|
||||
auto doc1 = R"({
|
||||
"status": {
|
||||
"1": "ACCEPTED"
|
||||
}
|
||||
})"_json;
|
||||
|
||||
auto add_op = coll1->add(doc1.dump(), CREATE);
|
||||
ASSERT_TRUE(add_op.ok());
|
||||
|
||||
ASSERT_TRUE(coll1->get_schema()["status.1"].sort);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user