mirror of
https://github.com/typesense/typesense.git
synced 2025-05-18 04:32:38 +08:00
Add approx_filter_ids_length
field.
This commit is contained in:
parent
889c1759e2
commit
d796391464
@ -125,12 +125,18 @@ private:
|
||||
|
||||
public:
|
||||
uint32_t seq_id = 0;
|
||||
// Collection name -> references
|
||||
/// Collection name -> references
|
||||
std::map<std::string, reference_filter_result_t> reference;
|
||||
Option<bool> status = Option(true);
|
||||
|
||||
/// Holds the upper-bound of the number of seq ids this iterator would match.
|
||||
/// Useful in a scenario where we need to differentiate between filter iterator not matching any document v/s filter
|
||||
/// iterator reaching it's end. (is_valid would be false in both these cases)
|
||||
uint32_t approx_filter_ids_length;
|
||||
|
||||
explicit filter_result_iterator_t(const std::string collection_name,
|
||||
Index const* const index, filter_node_t const* const filter_node);
|
||||
Index const* const index, filter_node_t const* const filter_node,
|
||||
uint32_t approx_filter_ids_length = UINT32_MAX);
|
||||
|
||||
~filter_result_iterator_t();
|
||||
|
||||
|
@ -835,10 +835,12 @@ uint32_t filter_result_iterator_t::and_scalar(const uint32_t* A, const uint32_t&
|
||||
}
|
||||
|
||||
filter_result_iterator_t::filter_result_iterator_t(const std::string collection_name, const Index *const index,
|
||||
const filter_node_t *const filter_node) :
|
||||
const filter_node_t *const filter_node,
|
||||
uint32_t approx_filter_ids_length) :
|
||||
collection_name(collection_name),
|
||||
index(index),
|
||||
filter_node(filter_node) {
|
||||
filter_node(filter_node),
|
||||
approx_filter_ids_length(approx_filter_ids_length) {
|
||||
if (filter_node == nullptr) {
|
||||
is_valid = false;
|
||||
return;
|
||||
|
@ -2713,7 +2713,8 @@ Option<bool> Index::search(std::vector<query_tokens_t>& field_query_tokens, cons
|
||||
return rearrange_op;
|
||||
}
|
||||
|
||||
auto filter_result_iterator = filter_result_iterator_t(collection_name, this, filter_tree_root);
|
||||
auto filter_result_iterator = filter_result_iterator_t(collection_name, this, filter_tree_root,
|
||||
approx_filter_ids_length);
|
||||
auto filter_init_op = filter_result_iterator.init_status();
|
||||
if (!filter_init_op.ok()) {
|
||||
return filter_init_op;
|
||||
|
@ -208,7 +208,7 @@ bool or_iterator_t::take_id(result_iter_state_t& istate, uint32_t id, bool& is_e
|
||||
return false;
|
||||
}
|
||||
|
||||
if (istate.fit != nullptr) {
|
||||
if (istate.fit != nullptr && istate.fit->approx_filter_ids_length > 0) {
|
||||
return (istate.fit->valid(id) == 1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user