Skip to content

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

refactor

krunale00ddd206b62
diff --git a/src/collection.cpp b/src/collection.cpp
index 07e7a58d..26d93944 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -2064,6 +2064,8 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
}
} else {
auto the_field = search_schema.at(a_facet.field_name);
+ bool should_return_parent = std::find(facet_return_parent.begin(), facet_return_parent.end(),
+ the_field.name) != facet_return_parent.end();
for(size_t fi = 0; fi < max_facets; fi++) {
// remap facet value hash with actual string
@@ -2091,8 +2093,7 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
}
}
- if(the_field.nested &&
- (std::find(facet_return_parent.begin(), facet_return_parent.end(), the_field.name) != facet_return_parent.end())) {
+ if(the_field.nested && should_return_parent) {
value = get_facet_parent(the_field.name, document);
}
diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cpp
index 5aa5ced9..1550ec74 100644
--- a/test/collection_faceting_test.cpp
+++ b/test/collection_faceting_test.cpp
@@ -1708,7 +1708,7 @@ TEST_F(CollectionFacetingTest, FacetingReturnParent) {
2, 2, false, "",
true, 0, max_score, 100,
0, 0, HASH, 30000,
- 2, "", {"value.r", "value.g", "value.b"});
+ 2, "", {});
if(!search_op.ok()) {
LOG(ERROR) << search_op.error();
@@ -1733,7 +1733,7 @@ TEST_F(CollectionFacetingTest, FacetingReturnParent) {
2, 2, false, "",
true, 0, max_score, 100,
0, 0, HASH, 30000,
- 2, "", {"value.r", "value.g", "value.b"});
+ 2, "", {"value.r"});
if(!search_op.ok()) {
LOG(ERROR) << search_op.error();