Fix regression in out_of in exclude_fields.

This commit is contained in:
Kishore Nallan 2022-10-07 10:55:05 +05:30
parent 36a0405416
commit af28e9d239
2 changed files with 29 additions and 0 deletions

View File

@ -993,6 +993,11 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query,
}
for(auto& f_name: exclude_fields) {
if(f_name == "out_of") {
// `out_of` is strictly a meta-field, but we handle it since it's useful
continue;
}
auto field_op = extract_field_name(f_name, search_schema, exclude_fields_vec, false, enable_nested_fields);
if(!field_op.ok()) {
return Option<nlohmann::json>(404, field_op.error());

View File

@ -1434,3 +1434,27 @@ TEST_F(CollectionSpecificMoreTest, VerifyDeletionOfFacetStringIndex) {
ASSERT_EQ(0, kv.second->size);
}
}
TEST_F(CollectionSpecificMoreTest, MustExcludeOutOf) {
nlohmann::json schema = R"({
"name": "coll1",
"fields": [
{"name": "title", "type": "string"}
]
})"_json;
Collection* coll1 = collectionManager.create_collection(schema).get();
nlohmann::json doc;
doc["title"] = "Sample Title 1";
ASSERT_TRUE(coll1->add(doc.dump()).ok());
spp::sparse_hash_set<std::string> include_fields;
auto res_op = coll1->search("*", {}, "", {}, {}, {2}, 10, 1,
FREQUENCY, {true}, 0, include_fields, {"out_of"});
ASSERT_TRUE(res_op.ok());
auto res = res_op.get();
ASSERT_EQ(1, res["hits"].size());
ASSERT_EQ(0, res.count("out_of"));
}