mirror of https://github.com/milvus-io/milvus.git
test: Add json key in [] test to verify issue 36718 (#36738)
related issue: #36718 --------- Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>pull/35825/head
parent
d1060c0e05
commit
621dbc9107
|
@ -1143,8 +1143,9 @@ def gen_json_data_for_diff_json_types(nb=ct.default_nb, start=0, json_type="json
|
||||||
Method: gen json data for different json types. Refer to RFC7159
|
Method: gen json data for different json types. Refer to RFC7159
|
||||||
"""
|
"""
|
||||||
if json_type == "json_embedded_object": # a json object with an embedd json object
|
if json_type == "json_embedded_object": # a json object with an embedd json object
|
||||||
return [{json_type: {"number": i, "level2": {"level2_number": i, "level2_float": i*1.0, "level2_str": str(i)}, "float": i*1.0}, "str": str(i)}
|
return [{json_type: {"number": i, "level2": {"level2_number": i, "level2_float": i*1.0, "level2_str": str(i), "level2_array": [i for i in range(i, i + 10)]},
|
||||||
for i in range(start, start + nb)]
|
"float": i*1.0}, "str": str(i), "array": [i for i in range(i, i + 10)], "bool": bool(i)}
|
||||||
|
for i in range(start, start + nb)]
|
||||||
if json_type == "json_objects_array": # a json-objects array with 2 json objects
|
if json_type == "json_objects_array": # a json-objects array with 2 json objects
|
||||||
return [[{"number": i, "level2": {"level2_number": i, "level2_float": i*1.0, "level2_str": str(i)}, "float": i*1.0, "str": str(i)},
|
return [[{"number": i, "level2": {"level2_number": i, "level2_float": i*1.0, "level2_str": str(i)}, "float": i*1.0, "str": str(i)},
|
||||||
{"number": i, "level2": {"level2_number": i, "level2_float": i*1.0, "level2_str": str(i)}, "float": i*1.0, "str": str(i)}
|
{"number": i, "level2": {"level2_number": i, "level2_float": i*1.0, "level2_str": str(i)}, "float": i*1.0, "str": str(i)}
|
||||||
|
|
|
@ -3555,7 +3555,7 @@ class TestQueryCount(TestcaseBase):
|
||||||
collection_w = self.init_collection_wrap(name=c_name, schema=schema)
|
collection_w = self.init_collection_wrap(name=c_name, schema=schema)
|
||||||
|
|
||||||
# 2. insert data
|
# 2. insert data
|
||||||
nb = 500
|
nb = 1000
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
data = [
|
data = [
|
||||||
cf.gen_vectors(nb, dim),
|
cf.gen_vectors(nb, dim),
|
||||||
|
@ -3574,15 +3574,21 @@ class TestQueryCount(TestcaseBase):
|
||||||
collection_w.load()
|
collection_w.load()
|
||||||
|
|
||||||
# 4. search and query with different expressions. All the expressions will return 10 results
|
# 4. search and query with different expressions. All the expressions will return 10 results
|
||||||
query_exprs = [f'{json_int} < 10 ', f'{json_float} <= 200.0 and {json_float} > 190.0',
|
query_exprs = [
|
||||||
f'{json_string} in ["1","2","3","4","5","6","7","8","9","10"]',
|
f'json_contains_any({json_embedded_object}["{json_embedded_object}"]["level2"]["level2_array"], [1,3,5,7,9])',
|
||||||
f'{json_bool} == true and {json_float} <= 10',
|
f'json_contains_any({json_embedded_object}["array"], [1,3,5,7,9])',
|
||||||
f'{json_array} == [4001,4002,4003,4004,4005,4006,4007,4008,4009,4010] or {json_int} < 9',
|
f'{json_int} < 10',
|
||||||
f'{json_embedded_object}["{json_embedded_object}"]["number"] < 10',
|
f'{json_float} <= 200.0 and {json_float} > 190.0',
|
||||||
f'{json_objects_array}[0]["level2"]["level2_str"] like "99%" and {json_objects_array}[1]["float"] > 100']
|
f'{json_string} in ["1","2","3","4","5","6","7","8","9","10"]',
|
||||||
|
f'{json_bool} == true and {json_float} <= 10',
|
||||||
|
f'{json_array} == [4001,4002,4003,4004,4005,4006,4007,4008,4009,4010] or {json_int} < 9',
|
||||||
|
f'{json_embedded_object}["{json_embedded_object}"]["number"] < 10',
|
||||||
|
f'{json_objects_array}[0]["level2"]["level2_str"] like "199%" and {json_objects_array}[1]["float"] >= 1990'
|
||||||
|
]
|
||||||
search_data = cf.gen_vectors(2, dim)
|
search_data = cf.gen_vectors(2, dim)
|
||||||
search_param = {}
|
search_param = {}
|
||||||
for expr in query_exprs:
|
for expr in query_exprs:
|
||||||
|
log.debug(f"query_expr: {expr}")
|
||||||
collection_w.query(expr=expr, output_fields=[count],
|
collection_w.query(expr=expr, output_fields=[count],
|
||||||
check_task=CheckTasks.check_query_results, check_items={exp_res: [{count: 10}]})
|
check_task=CheckTasks.check_query_results, check_items={exp_res: [{count: 10}]})
|
||||||
collection_w.search(data=search_data, anns_field=ct.default_float_vec_field_name,
|
collection_w.search(data=search_data, anns_field=ct.default_float_vec_field_name,
|
||||||
|
@ -3590,6 +3596,17 @@ class TestQueryCount(TestcaseBase):
|
||||||
check_task=CheckTasks.check_search_results,
|
check_task=CheckTasks.check_search_results,
|
||||||
check_items={"nq": 2, "limit": 10})
|
check_items={"nq": 2, "limit": 10})
|
||||||
|
|
||||||
|
# verify for issue #36718
|
||||||
|
for expr in [f'{json_embedded_object}["{json_embedded_object}"]["number"] in []',
|
||||||
|
f'{json_embedded_object}["{json_embedded_object}"] in []']:
|
||||||
|
log.debug(f"query_expr: {expr}")
|
||||||
|
collection_w.query(expr=expr, output_fields=[count],
|
||||||
|
check_task=CheckTasks.check_query_results, check_items={exp_res: [{count: 0}]})
|
||||||
|
collection_w.search(data=search_data, anns_field=ct.default_float_vec_field_name,
|
||||||
|
param=search_param, limit=10, expr=expr,
|
||||||
|
check_task=CheckTasks.check_search_results,
|
||||||
|
check_items={"nq": 2, "limit": 0})
|
||||||
|
|
||||||
@pytest.mark.tags(CaseLabel.L2)
|
@pytest.mark.tags(CaseLabel.L2)
|
||||||
def test_count_with_pagination_param(self):
|
def test_count_with_pagination_param(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue