Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Fix inheritance of sort field property for nested field.
Kishore Nallanda8cac463cbc
diff --git a/src/field.cpp b/src/field.cppindex 931bc419..1aa28eef 100644--- a/src/field.cpp+++ b/src/field.cpp@@ -505,7 +505,9 @@ bool field::flatten_obj(nlohmann::json& doc, nlohmann::json& value, bool has_arrflattened_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;}diff --git a/test/collection_nested_fields_test.cpp b/test/collection_nested_fields_test.cppindex 90232b7d..4e5a1fa0 100644--- a/test/collection_nested_fields_test.cpp+++ b/test/collection_nested_fields_test.cpp@@ -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);+}