mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 10:08:42 +08:00
fix: binary arith expression on inverted index (#35945)
issue: https://github.com/milvus-io/milvus/issues/35946 --------- Signed-off-by: longjiquan <jiquan.long@zilliz.com>
This commit is contained in:
parent
8eb1daf362
commit
11325d9ed5
@ -807,7 +807,7 @@ PhyBinaryArithOpEvalRangeExpr::ExecRangeVisitorImplForArray() {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
VectorPtr
|
VectorPtr
|
||||||
PhyBinaryArithOpEvalRangeExpr::ExecRangeVisitorImpl() {
|
PhyBinaryArithOpEvalRangeExpr::ExecRangeVisitorImpl() {
|
||||||
if (is_index_mode_) {
|
if (is_index_mode_ && IndexHasRawData<T>()) {
|
||||||
return ExecRangeVisitorImplForIndex<T>();
|
return ExecRangeVisitorImplForIndex<T>();
|
||||||
} else {
|
} else {
|
||||||
return ExecRangeVisitorImplForData<T>();
|
return ExecRangeVisitorImplForData<T>();
|
||||||
|
|||||||
@ -367,6 +367,25 @@ class SegmentExpr : public Expr {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool
|
||||||
|
IndexHasRawData() const {
|
||||||
|
typedef std::
|
||||||
|
conditional_t<std::is_same_v<T, std::string_view>, std::string, T>
|
||||||
|
IndexInnerType;
|
||||||
|
|
||||||
|
using Index = index::ScalarIndex<IndexInnerType>;
|
||||||
|
for (size_t i = current_index_chunk_; i < num_index_chunk_; i++) {
|
||||||
|
const Index& index =
|
||||||
|
segment_->chunk_scalar_index<IndexInnerType>(field_id_, i);
|
||||||
|
if (!index.HasRawData()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetNotUseIndex() {
|
SetNotUseIndex() {
|
||||||
use_index_ = false;
|
use_index_ = false;
|
||||||
|
|||||||
@ -2295,6 +2295,22 @@ class TestInvertedIndexValid(TestcaseBase):
|
|||||||
collection_w.create_index(scalar_fields[i], index_params=scalar_index_params, index_name=index_name)
|
collection_w.create_index(scalar_fields[i], index_params=scalar_index_params, index_name=index_name)
|
||||||
assert collection_w.has_index(index_name=index_name)[0] is True
|
assert collection_w.has_index(index_name=index_name)[0] is True
|
||||||
|
|
||||||
|
@pytest.mark.tags(CaseLabel.L0)
|
||||||
|
def test_binary_arith_expr_on_inverted_index(self):
|
||||||
|
prefix = "test_binary_arith_expr_on_inverted_index"
|
||||||
|
nb = 5000
|
||||||
|
collection_w, _, _, insert_ids, _ = self.init_collection_general(prefix, insert_data=True, is_index=True, is_all_data_type=True)
|
||||||
|
index_name = "test_binary_arith_expr_on_inverted_index"
|
||||||
|
scalar_index_params = {"index_type": "INVERTED"}
|
||||||
|
collection_w.release()
|
||||||
|
collection_w.create_index(ct.default_int64_field_name, index_params=scalar_index_params, index_name=index_name)
|
||||||
|
collection_w.load()
|
||||||
|
# query and verify result
|
||||||
|
res = collection_w.query(expr=f"{ct.default_int64_field_name} % 10 == 0")[0]
|
||||||
|
query_ids = set(map(lambda x: x[ct.default_int64_field_name], res))
|
||||||
|
filter_ids = set([_id for _id in insert_ids if _id % 10 == 0])
|
||||||
|
assert query_ids == set(filter_ids)
|
||||||
|
|
||||||
|
|
||||||
class TestBitmapIndex(TestcaseBase):
|
class TestBitmapIndex(TestcaseBase):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user