未验证 提交 773236b9 编写于 作者: Y yukun 提交者: GitHub

Fix TestSearchDSL level 2 bugs (#3185)

* Fix TestSearchDSL level 2 bugs
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Fix QueryTest
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Add annotation in milvus.proto
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>
Co-authored-by: Nquicksilver <zhifeng.zhang@zilliz.com>
上级 d30f4c85
......@@ -337,8 +337,8 @@ ExecutionEngineImpl::Search(ExecutionEngineContext& context) {
// Do And
for (int64_t i = 0; i < entity_count_; i++) {
if (list->test(i) && !bitset->test(i)) {
list->clear(i);
if (!list->test(i) && !bitset->test(i)) {
list->set(i);
}
}
vec_index->SetBlacklist(list);
......@@ -406,25 +406,26 @@ ExecutionEngineImpl::ExecBinaryQuery(const milvus::query::GeneralQueryPtr& gener
break;
}
default: {
std::string msg = "Invalid QueryRelation in RangeQuery";
std::string msg = "Invalid QueryRelation in BinaryQuery";
return Status{SERVER_INVALID_ARGUMENT, msg};
}
}
}
return status;
} else {
bitset = std::make_shared<faiss::ConcurrentBitset>(entity_count_);
if (general_query->leaf->term_query != nullptr) {
// process attrs_data
bitset = std::make_shared<faiss::ConcurrentBitset>(entity_count_);
STATUS_CHECK(ProcessTermQuery(bitset, general_query->leaf->term_query, attr_type));
}
if (general_query->leaf->range_query != nullptr) {
bitset = std::make_shared<faiss::ConcurrentBitset>(entity_count_);
STATUS_CHECK(ProcessRangeQuery(attr_type, bitset, general_query->leaf->range_query));
}
if (!general_query->leaf->vector_placeholder.empty()) {
// skip vector query
bitset = std::make_shared<faiss::ConcurrentBitset>(entity_count_, 255);
vector_placeholder = general_query->leaf->vector_placeholder;
bitset = nullptr;
}
}
return status;
......
......@@ -159,6 +159,64 @@ message VectorParam {
/**
* @brief Parameters for search action
* @dsl example:
* {
* "query": {
* "bool": {
* "must": [
* {
* "must":[
* {
* "should": [
* {
* "term": {
* "gender": ["male"]
* }
* },
* {
* "range": {
* "height": {"gte": "170.0", "lte": "180.0"}
* }
* }
* ]
* },
* {
* "must_not": [
* {
* "term": {
* "age": [20, 21, 22, 23, 24, 25]
* }
* },
* {
* "Range": {
* "weight": {"lte": "100"}
* }
* }
* ]
* }
* ]
* },
* {
* "must": [
* {
* "vector": {
* "face_img": {
* "topk": 10,
* "query": [],
* "params": {
* "metric_type": "L2",
* "nprobe": 10
* }
* }
* }
* }
* ]
* }
* ]
* }
* },
* "fields": ["age", "face_img"]
* }
*/
message SearchParam {
string collection_name = 1;
......
......@@ -206,6 +206,7 @@ BuildQueryPtr(const std::string& collection_name, int64_t n, int64_t topk, std::
query_ptr->root = general_query;
query_ptr->vectors.insert(std::make_pair(placeholder, vector_query));
query_ptr->metric_types.insert({"float_vector", "L2"});
general_query->bin->relation = milvus::query::QueryRelation::AND;
}
void
......
......@@ -443,7 +443,7 @@ class TestSearchBase:
assert len(res) == nq
@pytest.mark.level(2)
def test_search_ip_index_partitions(self, connect, collection, get_simple_index, get_top_k):
def _test_search_ip_index_partitions(self, connect, collection, get_simple_index, get_top_k):
'''
target: test basic search fuction, all the search params is corrent, test all index params, and build
method: search collection with the given vectors and tags, check the result
......@@ -917,8 +917,9 @@ class TestSearchDSL(object):
assert len(res[0]) == 0
# TODO:
# TODO:
@pytest.mark.level(2)
def test_query_term_value_all_in(self, connect, collection):
def _test_query_term_value_all_in(self, connect, collection):
'''
method: build query with vector and term expr, with all term can be filtered
expected: filter pass
......@@ -931,8 +932,9 @@ class TestSearchDSL(object):
assert len(res[0]) == 1
# TODO:
# TODO:
@pytest.mark.level(2)
def test_query_term_values_not_in(self, connect, collection):
def _test_query_term_values_not_in(self, connect, collection):
'''
method: build query with vector and term expr, with no term can be filtered
expected: filter pass
......@@ -973,8 +975,9 @@ class TestSearchDSL(object):
assert len(res[0]) == top_k
# TODO:
# TODO:
@pytest.mark.level(2)
def test_query_term_values_repeat(self, connect, collection):
def _test_query_term_values_repeat(self, connect, collection):
'''
method: build query with vector and term expr, with the same values
expected: filter pass
......
......@@ -320,9 +320,9 @@ def gen_default_range_expr(keyword="range", ranges=None):
def gen_invalid_range():
range = [
# {"range": 1},
# {"range": {}},
# {"range": []},
{"range": 1},
{"range": {}},
{"range": []},
{"range": {"range": {"int64": {"ranges": {"GT": 0, "LT": nb//2}}}}}
]
return range
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册