mirror of
https://github.com/typesense/typesense.git
synced 2025-05-21 14:12:27 +08:00
Better guards for top_k truncation.
This commit is contained in:
parent
32a85a472f
commit
f8e6468a7b
@ -4953,9 +4953,13 @@ void Collection::hide_credential(nlohmann::json& json, const std::string& creden
|
||||
}
|
||||
}
|
||||
Option<bool> Collection::truncate_after_top_k(const string &field_name, size_t k) {
|
||||
std::shared_lock slock(mutex);
|
||||
|
||||
std::vector<uint32_t> seq_ids;
|
||||
auto op = index->seq_ids_outside_top_k(field_name, k, seq_ids);
|
||||
|
||||
slock.unlock();
|
||||
|
||||
if(!op.ok()) {
|
||||
return op;
|
||||
}
|
||||
|
@ -6315,9 +6315,10 @@ size_t Index::num_seq_ids() const {
|
||||
|
||||
Option<bool> Index::seq_ids_outside_top_k(const std::string& field_name, size_t k,
|
||||
std::vector<uint32_t>& outside_seq_ids) {
|
||||
std::shared_lock lock(mutex);
|
||||
auto field_it = numerical_index.find(field_name);
|
||||
|
||||
if(field_it == sort_index.end()) {
|
||||
if(field_it == numerical_index.end()) {
|
||||
return Option<bool>(400, "Field not found in numerical index.");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user