mirror of
https://github.com/typesense/typesense.git
synced 2025-05-22 06:40:30 +08:00
Fix regression in out_of
in exclude_fields.
This commit is contained in:
parent
36a0405416
commit
af28e9d239
@ -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());
|
||||
|
@ -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"));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user