mirror of
https://github.com/typesense/typesense.git
synced 2025-05-20 05:32:30 +08:00
Merge pull request #1381 from happy-san/fit_fix
Fix `filter_result_iterator_t::compute_result`.
This commit is contained in:
commit
08040ba60c
@ -1770,22 +1770,15 @@ void filter_result_iterator_t::compute_result() {
|
||||
filter_result_t::or_filter_results(left_it->filter_result, right_it->filter_result, filter_result);
|
||||
}
|
||||
|
||||
// In a complex filter query a sub-expression might not match any document while the full expression does match
|
||||
// at least one document. If the full expression doesn't match any document, we return early in the search.
|
||||
if (filter_result.count == 0) {
|
||||
is_valid = false;
|
||||
LOG(ERROR) << "filter_result.count is 0 " << filter_node->filter_query;
|
||||
return;
|
||||
} else if (result_index != 0) {
|
||||
result_index = 0;
|
||||
LOG(ERROR) << "result_index is not 0 " << filter_node->filter_query;
|
||||
return;
|
||||
}
|
||||
|
||||
if (result_index >= filter_result.count) {
|
||||
is_valid = false;
|
||||
LOG(ERROR) << "result_index is greater than filter_result.count " << filter_node->filter_query;
|
||||
is_filter_result_initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
result_index = 0;;
|
||||
seq_id = filter_result.docs[result_index];
|
||||
is_filter_result_initialized = true;
|
||||
approx_filter_ids_length = filter_result.count;
|
||||
|
@ -2116,6 +2116,10 @@ TEST_F(CollectionFilteringTest, ComplexFilterQuery) {
|
||||
{}, sort_fields_desc, {0}, 10, 1, FREQUENCY, {false}).get();
|
||||
ASSERT_EQ(0, results["hits"].size());
|
||||
|
||||
results = coll->search("*", {"name"}, "(age:>50 && rating:>5) || years:<2000",
|
||||
{}, sort_fields_desc, {0}, 10, 1, FREQUENCY, {false}).get();
|
||||
ASSERT_EQ(2, results["hits"].size());
|
||||
|
||||
results = coll->search("Jeremy", {"name"}, "(age:>50 || rating:>5) && years:<2000",
|
||||
{}, sort_fields_desc, {0}, 10, 1, FREQUENCY, {false}).get();
|
||||
ASSERT_EQ(2, results["hits"].size());
|
||||
|
Loading…
x
Reference in New Issue
Block a user