mirror of https://github.com/milvus-io/milvus.git
Update creating index behavior (#21435)
Signed-off-by: Binbin Lv <binbin.lv@zilliz.com>pull/21453/head
parent
e6d2849c9a
commit
dffc47a6b6
|
@ -168,7 +168,7 @@ class TestcaseBase(Base):
|
|||
|
||||
def init_collection_general(self, prefix="test", insert_data=False, nb=ct.default_nb,
|
||||
partition_num=0, is_binary=False, is_all_data_type=False,
|
||||
auto_id=False, dim=ct.default_dim, is_index=False,
|
||||
auto_id=False, dim=ct.default_dim, is_index=True,
|
||||
primary_field=ct.default_int64_field_name, is_flush=True, name=None, **kwargs):
|
||||
"""
|
||||
target: create specified collections
|
||||
|
@ -209,13 +209,13 @@ class TestcaseBase(Base):
|
|||
assert collection_w.is_empty is False
|
||||
assert collection_w.num_entities == nb
|
||||
# This condition will be removed after auto index feature
|
||||
if not is_index:
|
||||
if is_index:
|
||||
if is_binary:
|
||||
collection_w.create_index(ct.default_binary_vec_field_name, ct.default_bin_flat_index)
|
||||
else:
|
||||
collection_w.create_index(ct.default_float_vec_field_name, ct.default_flat_index)
|
||||
collection_w.load()
|
||||
elif not is_index:
|
||||
elif is_index:
|
||||
if is_binary:
|
||||
collection_w.create_index(ct.default_binary_vec_field_name, ct.default_bin_flat_index)
|
||||
else:
|
||||
|
|
|
@ -2573,7 +2573,7 @@ class TestLoadCollection(TestcaseBase):
|
|||
method: create a collection without index, then load
|
||||
expected: raise exception
|
||||
"""
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=False)[0]
|
||||
collection_w.load(check_task=CheckTasks.err_res,
|
||||
check_items={"err_code": 1,
|
||||
"err_msg": "index not exist"})
|
||||
|
@ -2611,7 +2611,7 @@ class TestReleaseAdvanced(TestcaseBase):
|
|||
"""
|
||||
self._connect()
|
||||
partition_num = 1
|
||||
collection_w = self.init_collection_general(prefix, True, 10, partition_num, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, 10, partition_num, is_index=False)[0]
|
||||
collection_w.create_index(ct.default_float_vec_field_name, index_params=ct.default_flat_index)
|
||||
par = collection_w.partitions
|
||||
par_name = par[partition_num].name
|
||||
|
@ -2637,7 +2637,7 @@ class TestReleaseAdvanced(TestcaseBase):
|
|||
"""
|
||||
self._connect()
|
||||
partition_num = 1
|
||||
collection_w = self.init_collection_general(prefix, True, 10, partition_num, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, 10, partition_num, is_index=False)[0]
|
||||
collection_w.create_index(ct.default_float_vec_field_name, index_params=ct.default_flat_index)
|
||||
par = collection_w.partitions
|
||||
par_name = par[partition_num].name
|
||||
|
@ -2692,7 +2692,7 @@ class TestLoadPartition(TestcaseBase):
|
|||
self._connect()
|
||||
partition_num = 1
|
||||
collection_w = self.init_collection_general(prefix, True, ct.default_nb, partition_num,
|
||||
is_binary=True, is_index=True)[0]
|
||||
is_binary=True, is_index=False)[0]
|
||||
|
||||
# for metric_type in ct.binary_metrics:
|
||||
binary_index["metric_type"] = metric_type
|
||||
|
|
|
@ -321,7 +321,7 @@ class TestDeleteOperation(TestcaseBase):
|
|||
expected: assert index and deleted id not in search result
|
||||
"""
|
||||
# create collection, insert tmp_nb, flush and load
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_index=True)[0:2]
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_index=False)[0:2]
|
||||
|
||||
# create index
|
||||
index_params = {"index_type": "IVF_SQ8",
|
||||
|
@ -1140,7 +1140,7 @@ class TestDeleteString(TestcaseBase):
|
|||
expected: assert index and deleted id not in search result
|
||||
"""
|
||||
# create collection, insert tmp_nb, flush and load
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_index=True,
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_index=False,
|
||||
primary_field=ct.default_string_field_name)[0:2]
|
||||
|
||||
# create index
|
||||
|
|
|
@ -222,7 +222,7 @@ class TestIndexOperation(TestcaseBase):
|
|||
method: create two different indexes with default index name
|
||||
expected: create successfully
|
||||
"""
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=False)[0]
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"}
|
||||
collection_w.create_index(default_field_name, default_index)
|
||||
collection_w.create_index(ct.default_int64_field_name, {})
|
||||
|
@ -234,7 +234,7 @@ class TestIndexOperation(TestcaseBase):
|
|||
method: create index on scalar field and load
|
||||
expected: raise exception
|
||||
"""
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=False)[0]
|
||||
collection_w.create_index(ct.default_int64_field_name, {})
|
||||
collection_w.load(check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 1, ct.err_msg: "there is no vector index on collection, "
|
||||
|
@ -1255,7 +1255,7 @@ class TestIndexInvalid(TestcaseBase):
|
|||
2. drop the index
|
||||
expected: raise exception
|
||||
"""
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=False)[0]
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", default_index)
|
||||
collection_w.load()
|
||||
|
@ -1273,7 +1273,7 @@ class TestIndexInvalid(TestcaseBase):
|
|||
2. set annoy index param n_trees type invalid(not int)
|
||||
expected: raise exception
|
||||
"""
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=False)[0]
|
||||
index_annoy = {"index_type": "ANNOY", "params": {"n_trees": n_trees}, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", index_annoy,
|
||||
check_task=CheckTasks.err_res,
|
||||
|
|
|
@ -748,7 +748,7 @@ class TestQueryParams(TestcaseBase):
|
|||
expected: verify query result
|
||||
"""
|
||||
# init collection with fields: int64, float, float_vec
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_index=True)[0:2]
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_index=False)[0:2]
|
||||
df = vectors[0]
|
||||
|
||||
# query with output_fields=["*", float_vector)
|
||||
|
@ -1287,7 +1287,7 @@ class TestQueryOperation(TestcaseBase):
|
|||
3. query
|
||||
expected: query result is correct
|
||||
"""
|
||||
collection_w, vectors, binary_raw_vectors = self.init_collection_general(prefix, insert_data=True, is_index=True)[0:3]
|
||||
collection_w, vectors, binary_raw_vectors = self.init_collection_general(prefix, insert_data=True, is_index=False)[0:3]
|
||||
|
||||
default_field_name = ct.default_float_vec_field_name
|
||||
collection_w.create_index(default_field_name, default_index_params)
|
||||
|
@ -1354,7 +1354,7 @@ class TestQueryOperation(TestcaseBase):
|
|||
method: create index and specify vec field as output field
|
||||
expected: return primary field and vec field
|
||||
"""
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_binary=True, is_index=True)[0:2]
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_binary=True, is_index=False)[0:2]
|
||||
fields = [ct.default_int64_field_name, ct.default_binary_vec_field_name]
|
||||
collection_w.create_index(ct.default_binary_vec_field_name, binary_index_params)
|
||||
assert collection_w.has_index()[0]
|
||||
|
@ -1538,7 +1538,7 @@ class TestqueryString(TestcaseBase):
|
|||
method: query string expr with binary
|
||||
expected: verify query successfully
|
||||
"""
|
||||
collection_w, vectors= self.init_collection_general(prefix, insert_data=True, is_binary=True, is_index=True)[0:2]
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_binary=True, is_index=False)[0:2]
|
||||
collection_w.create_index(ct.default_binary_vec_field_name, binary_index_params)
|
||||
collection_w.load()
|
||||
assert collection_w.has_index()[0]
|
||||
|
@ -1685,7 +1685,7 @@ class TestqueryString(TestcaseBase):
|
|||
expected: query successfully
|
||||
"""
|
||||
# 1. create a collection
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=False, is_index=True)[0:2]
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=False, is_index=False)[0:2]
|
||||
|
||||
nb = 3000
|
||||
df = cf.gen_default_list_data(nb)
|
||||
|
@ -1712,7 +1712,7 @@ class TestqueryString(TestcaseBase):
|
|||
method: create a collection and build diskann index
|
||||
expected: verify query result
|
||||
"""
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_index=True)[0:2]
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, is_index=False)[0:2]
|
||||
|
||||
collection_w.create_index(ct.default_float_vec_field_name, ct.default_diskann_index)
|
||||
assert collection_w.has_index()[0]
|
||||
|
@ -1731,7 +1731,7 @@ class TestqueryString(TestcaseBase):
|
|||
method: create a collection with string pk and build diskann index
|
||||
expected: verify query result
|
||||
"""
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, primary_field=ct.default_string_field_name, is_index=True)[0:2]
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True, primary_field=ct.default_string_field_name, is_index=False)[0:2]
|
||||
collection_w.create_index(ct.default_float_vec_field_name, ct.default_diskann_index)
|
||||
assert collection_w.has_index()[0]
|
||||
collection_w.load()
|
||||
|
@ -1750,7 +1750,7 @@ class TestqueryString(TestcaseBase):
|
|||
expected: query successfully
|
||||
"""
|
||||
# 1. create a collection
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=False, is_index=True)[0:2]
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=False, is_index=False)[0:2]
|
||||
|
||||
nb = 3000
|
||||
df = cf.gen_default_list_data(nb)
|
||||
|
|
|
@ -312,7 +312,7 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
pytest.skip("skip in FLAT index")
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True, 5000,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
# 2. create index and load
|
||||
default_index = {"index_type": index, "params": params, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", default_index)
|
||||
|
@ -340,7 +340,7 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
expected: raise exception and report the error
|
||||
"""
|
||||
# 1. initialize with data
|
||||
collection_w = self.init_collection_general(prefix, True, 3000, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, 3000, is_index=False)[0]
|
||||
# 2. create annoy index and load
|
||||
index_annoy = {"index_type": "ANNOY", "params": {"n_trees": 512}, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", index_annoy)
|
||||
|
@ -502,7 +502,7 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
dim = 8
|
||||
collection_w, _vectors, _, insert_ids = self.init_collection_general(prefix, True,
|
||||
nb, dim=dim,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
index_param = {"index_type": "IVF_FLAT", "metric_type": "L2", "params": {"nlist": 100}}
|
||||
collection_w.create_index("float_vector", index_param)
|
||||
collection_w.load()
|
||||
|
@ -586,7 +586,7 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
partition_num = 1
|
||||
collection_w = self.init_collection_general(prefix, True, 10, partition_num, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, 10, partition_num, is_index=False)[0]
|
||||
collection_w.create_index(ct.default_float_vec_field_name, index_params=ct.default_flat_index)
|
||||
par = collection_w.partitions
|
||||
par_name = par[partition_num].name
|
||||
|
@ -689,7 +689,7 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
partition_num = 1
|
||||
collection_w = self.init_collection_general(prefix, True, 1000, partition_num, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, 1000, partition_num, is_index=False)[0]
|
||||
# 2. delete partitions
|
||||
log.info("test_search_partition_deleted: deleting a partition")
|
||||
par = collection_w.partitions
|
||||
|
@ -720,7 +720,7 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True, 5000,
|
||||
partition_num=1,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
# 2. create different index
|
||||
if params.get("m"):
|
||||
if (default_dim % params["m"]) != 0:
|
||||
|
@ -748,7 +748,7 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
expected: raise exception and report the error
|
||||
"""
|
||||
# 1. initialize with data
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=False)[0]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", default_index)
|
||||
|
@ -769,7 +769,7 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
expected: raise exception and report the error
|
||||
"""
|
||||
# 1. initialize with binary data
|
||||
collection_w = self.init_collection_general(prefix, True, is_binary=True, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, is_binary=True, is_index=False)[0]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "BIN_IVF_FLAT", "params": {"nlist": 128}, "metric_type": "JACCARD"}
|
||||
collection_w.create_index("binary_vector", default_index)
|
||||
|
@ -1316,7 +1316,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
"""
|
||||
# 1. connect, create collection and insert data
|
||||
self._connect()
|
||||
collection_w = self.init_collection_general(prefix, False, dim=dim, is_index=True)[0]
|
||||
collection_w = self.init_collection_general(prefix, False, dim=dim, is_index=False)[0]
|
||||
dataframe = cf.gen_default_dataframe_data(dim=dim, start=-1500)
|
||||
collection_w.insert(dataframe)
|
||||
|
||||
|
@ -1447,7 +1447,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
HNSW_index_params = {"M": M, "efConstruction": efConstruction}
|
||||
HNSW_index = {"index_type": "HNSW", "params": HNSW_index_params, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", HNSW_index)
|
||||
|
@ -1480,7 +1480,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
HNSW_index_params = {"M": M, "efConstruction": efConstruction}
|
||||
HNSW_index = {"index_type": "HNSW", "params": HNSW_index_params, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", HNSW_index)
|
||||
|
@ -1511,7 +1511,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, 5000,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
# 2. create index and load
|
||||
if params.get("m"):
|
||||
if (dim % params["m"]) != 0:
|
||||
|
@ -1551,7 +1551,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, 5000,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=min_dim, is_index=True)[0:5]
|
||||
dim=min_dim, is_index=False)[0:5]
|
||||
# 2. create index and load
|
||||
if params.get("m"):
|
||||
params["m"] = min_dim
|
||||
|
@ -1589,7 +1589,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, 5000,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
# 2. create different index
|
||||
if params.get("m"):
|
||||
if (dim % params["m"]) != 0:
|
||||
|
@ -1709,7 +1709,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, nb,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
is_index=True)[0:5]
|
||||
is_index=False)[0:5]
|
||||
|
||||
# 2. create index
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"}
|
||||
|
@ -1746,7 +1746,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=dim,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"}
|
||||
|
@ -1781,7 +1781,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=dim,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create index
|
||||
nlist = 128
|
||||
|
@ -1816,7 +1816,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w = self.init_collection_general(prefix, True, auto_id=auto_id,
|
||||
dim=dim, is_index=True)[0]
|
||||
dim=dim, is_index=False)[0]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create empty partition
|
||||
partition_name = "search_partition_empty"
|
||||
|
@ -1853,7 +1853,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
is_binary=True,
|
||||
auto_id=auto_id,
|
||||
dim=dim,
|
||||
is_index=True,
|
||||
is_index=False,
|
||||
is_flush=is_flush)[0:5]
|
||||
# 2. create index
|
||||
default_index = {"index_type": index, "params": {"nlist": 128}, "metric_type": "JACCARD"}
|
||||
|
@ -1892,7 +1892,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
is_binary=True,
|
||||
auto_id=auto_id,
|
||||
dim=dim,
|
||||
is_index=True,
|
||||
is_index=False,
|
||||
is_flush=is_flush)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": index, "params": {"nlist": 128}, "metric_type": "HAMMING"}
|
||||
|
@ -1931,7 +1931,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
is_binary=True,
|
||||
auto_id=auto_id,
|
||||
dim=dim,
|
||||
is_index=True,
|
||||
is_index=False,
|
||||
is_flush=is_flush)[0:4]
|
||||
log.info("auto_id= %s, _async= %s" % (auto_id, _async))
|
||||
# 2. create index
|
||||
|
@ -1974,7 +1974,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
dim = 8
|
||||
collection_w, _, binary_raw_vector, insert_ids, time_stamp \
|
||||
= self.init_collection_general(prefix, True, default_nb, is_binary=True, auto_id=auto_id,
|
||||
dim=dim, is_index=True, is_flush=is_flush)[0:5]
|
||||
dim=dim, is_index=False, is_flush=is_flush)[0:5]
|
||||
# 2. create index
|
||||
default_index = {"index_type": index, "params": {"nlist": 128}, "metric_type": "SUBSTRUCTURE"}
|
||||
collection_w.create_index("binary_vector", default_index)
|
||||
|
@ -2010,7 +2010,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
dim = 8
|
||||
collection_w, _, binary_raw_vector, insert_ids, time_stamp \
|
||||
= self.init_collection_general(prefix, True, default_nb, is_binary=True, auto_id=auto_id,
|
||||
dim=dim, is_index=True, is_flush=is_flush)[0:5]
|
||||
dim=dim, is_index=False, is_flush=is_flush)[0:5]
|
||||
# 2. create index
|
||||
default_index = {"index_type": index, "params": {"nlist": 128}, "metric_type": "SUPERSTRUCTURE"}
|
||||
collection_w.create_index("binary_vector", default_index)
|
||||
|
@ -2122,7 +2122,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
nb = 1000
|
||||
collection_w, _vectors, _, insert_ids = self.init_collection_general(prefix, True,
|
||||
nb, dim=dim,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
|
||||
# filter result with expression in collection
|
||||
_vectors = _vectors[0]
|
||||
|
@ -2172,7 +2172,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
collection_w, _vectors, _, insert_ids = self.init_collection_general(prefix, True, nb,
|
||||
is_all_data_type=True,
|
||||
auto_id=auto_id,
|
||||
dim=dim, is_index=True)[0:4]
|
||||
dim=dim, is_index=False)[0:4]
|
||||
|
||||
# 2. create index
|
||||
index_param = {"index_type": "IVF_FLAT", "metric_type": "L2", "params": {"nlist": 100}}
|
||||
|
@ -2225,7 +2225,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
collection_w, _vectors, _, insert_ids = self.init_collection_general(prefix, True, nb,
|
||||
auto_id=True,
|
||||
dim=dim,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
|
||||
# filter result with expression in collection
|
||||
_vectors = _vectors[0]
|
||||
|
@ -2606,7 +2606,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
nb = 10000
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True,
|
||||
nb, dim=dim,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
|
||||
|
||||
# 2. create index
|
||||
|
@ -2639,8 +2639,8 @@ class TestCollectionSearch(TestcaseBase):
|
|||
# 1. initialize with data
|
||||
nb = 10000
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True,
|
||||
nb, dim=dim,
|
||||
is_index=True)[0:4]
|
||||
nb, dim=dim,
|
||||
is_index=False)[0:4]
|
||||
|
||||
|
||||
# 2. create index
|
||||
|
@ -2918,7 +2918,7 @@ class TestCollectionSearch(TestcaseBase):
|
|||
self._connect()
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, False, nb,
|
||||
auto_id=auto_id,
|
||||
dim=dim, is_index=True)[0:4]
|
||||
dim=dim, is_index=False)[0:4]
|
||||
collection_w.create_partition(partition_name)
|
||||
insert_ids = cf.insert_data(collection_w, nb, auto_id=auto_id, dim=dim)[3]
|
||||
collection_w.create_index(default_search_field, default_index_params, index_name=index_name)
|
||||
|
@ -2998,7 +2998,7 @@ class TestSearchBase(TestcaseBase):
|
|||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, nq,
|
||||
partition_num=1,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create patition
|
||||
partition_name = "search_partition_empty"
|
||||
|
@ -3047,7 +3047,7 @@ class TestSearchBase(TestcaseBase):
|
|||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, nq,
|
||||
partition_num=1,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create patition
|
||||
partition_name = ct.default_partition_name
|
||||
|
@ -3080,7 +3080,7 @@ class TestSearchBase(TestcaseBase):
|
|||
dim = ct.default_dim
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, nq,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create ip index
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "IP"}
|
||||
|
@ -3107,7 +3107,7 @@ class TestSearchBase(TestcaseBase):
|
|||
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, nq,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create ip index
|
||||
default_index = {"index_type": index, "params": params, "metric_type": "IP"}
|
||||
|
@ -3164,7 +3164,7 @@ class TestSearchBase(TestcaseBase):
|
|||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, nq,
|
||||
partition_num=1,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create patition
|
||||
partition_name = "search_partition_empty"
|
||||
|
@ -3207,7 +3207,7 @@ class TestSearchBase(TestcaseBase):
|
|||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, nq,
|
||||
partition_num=1,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
# 2. create patition
|
||||
par_name = collection_w.partitions[0].name
|
||||
|
@ -3481,7 +3481,7 @@ class TestsearchString(TestcaseBase):
|
|||
nb = 1000
|
||||
collection_w, _vectors, _, insert_ids = self.init_collection_general(prefix, True,
|
||||
nb, dim=dim,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
|
||||
# filter result with expression in collection
|
||||
_vectors = _vectors[0]
|
||||
|
@ -3532,7 +3532,7 @@ class TestsearchString(TestcaseBase):
|
|||
collection_w, _, binary_raw_vector, insert_ids = self.init_collection_general(prefix, True, 2,
|
||||
is_binary=True,
|
||||
dim=dim,
|
||||
is_index=True,
|
||||
is_index=False,
|
||||
primary_field=ct.default_string_field_name)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "BIN_IVF_FLAT", "params": {"nlist": 128}, "metric_type": "JACCARD"}
|
||||
|
@ -3567,7 +3567,7 @@ class TestsearchString(TestcaseBase):
|
|||
is_binary=True,
|
||||
auto_id=auto_id,
|
||||
dim=dim,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "BIN_IVF_FLAT", "params": {"nlist": 128}, "metric_type": "JACCARD"}
|
||||
collection_w.create_index("binary_vector", default_index)
|
||||
|
@ -3596,7 +3596,7 @@ class TestsearchString(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = \
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_binary=True, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_binary=True, is_index=False)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "BIN_IVF_FLAT", "params": {"nlist": 128}, "metric_type": "JACCARD"}
|
||||
collection_w.create_index("binary_vector", default_index)
|
||||
|
@ -3629,10 +3629,10 @@ class TestsearchString(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = \
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=default_dim, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=default_dim, is_index=False)[0:4]
|
||||
index_param = {"index_type": "IVF_FLAT", "metric_type": "L2", "params": {"nlist": 100}}
|
||||
collection_w.create_index("float_vector", index_param, index_name="a")
|
||||
index_param_two ={}
|
||||
index_param_two = {}
|
||||
collection_w.create_index("varchar", index_param_two, index_name="b")
|
||||
collection_w.load()
|
||||
# 2. search
|
||||
|
@ -3665,12 +3665,12 @@ class TestsearchString(TestcaseBase):
|
|||
# create collection, insert tmp_nb, flush and load
|
||||
collection_w, vectors, _, insert_ids = self.init_collection_general(prefix, insert_data=True,
|
||||
primary_field=ct.default_string_field_name,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
|
||||
# create index
|
||||
index_params_one = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}}
|
||||
collection_w.create_index(ct.default_float_vec_field_name, index_params_one, index_name=index_name1)
|
||||
index_params_two ={}
|
||||
index_params_two = {}
|
||||
collection_w.create_index(ct.default_string_field_name, index_params=index_params_two, index_name=index_name2)
|
||||
assert collection_w.has_index(index_name=index_name2)
|
||||
|
||||
|
@ -3745,7 +3745,7 @@ class TestsearchString(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, _= \
|
||||
self.init_collection_general(prefix, False, primary_field=ct.default_int64_field_name, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, False, primary_field=ct.default_int64_field_name, is_index=False)[0:4]
|
||||
|
||||
nb = 3000
|
||||
data = cf.gen_default_list_data(nb)
|
||||
|
@ -4010,7 +4010,7 @@ class TestsearchPagination(TestcaseBase):
|
|||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
is_index=True)[0:4]
|
||||
is_index=False)[0:4]
|
||||
vectors = [[random.random() for _ in range(default_dim)] for _ in range(default_nq)]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"}
|
||||
|
@ -4174,7 +4174,7 @@ class TestsearchPagination(TestcaseBase):
|
|||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, 1000,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=dim, is_index=True)[0:5]
|
||||
dim=dim, is_index=False)[0:5]
|
||||
# 2. create index and load
|
||||
if params.get("m"):
|
||||
if (dim % params["m"]) != 0:
|
||||
|
@ -4299,8 +4299,8 @@ class TestsearchDiskann(TestcaseBase):
|
|||
|
||||
nb = 2000
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True, auto_id=auto_id,
|
||||
nb=nb, dim=dim,
|
||||
is_index=True)[0:4]
|
||||
nb=nb, dim=dim,
|
||||
is_index=False)[0:4]
|
||||
|
||||
# 2. create index
|
||||
default_index = {"index_type": "DISKANN", "metric_type":"L2", "params": {}}
|
||||
|
@ -4338,7 +4338,7 @@ class TestsearchDiskann(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = \
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=False)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "DISKANN", "metric_type":"L2", "params": {}}
|
||||
collection_w.create_index(ct.default_float_vec_field_name, default_index)
|
||||
|
@ -4369,7 +4369,7 @@ class TestsearchDiskann(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = \
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=False)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "DISKANN", "metric_type":"L2", "params": {}}
|
||||
collection_w.create_index(ct.default_float_vec_field_name, default_index)
|
||||
|
@ -4400,7 +4400,7 @@ class TestsearchDiskann(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = \
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=False)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "DISKANN", "metric_type":"L2", "params": {}}
|
||||
collection_w.create_index(ct.default_float_vec_field_name, default_index)
|
||||
|
@ -4428,7 +4428,7 @@ class TestsearchDiskann(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = \
|
||||
self.init_collection_general(prefix, True, auto_id=False, dim=dim, is_index=True, primary_field=ct.default_string_field_name)[0:4]
|
||||
self.init_collection_general(prefix, True, auto_id=False, dim=dim, is_index=False, primary_field=ct.default_string_field_name)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "DISKANN", "metric_type":"L2", "params": {}}
|
||||
collection_w.create_index(ct.default_float_vec_field_name, default_index)
|
||||
|
@ -4460,7 +4460,7 @@ class TestsearchDiskann(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, ids = \
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=False)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "DISKANN", "metric_type":"L2", "params": {}}
|
||||
collection_w.create_index(ct.default_float_vec_field_name, default_index)
|
||||
|
@ -4502,9 +4502,9 @@ class TestsearchDiskann(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, ids = \
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim, is_index=False)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "DISKANN", "metric_type":"L2", "params": {}}
|
||||
default_index = {"index_type": "DISKANN", "metric_type": "L2", "params": {}}
|
||||
collection_w.create_index(ct.default_float_vec_field_name, default_index, index_name=index_name1)
|
||||
index_params_one = {}
|
||||
collection_w.create_index("float", index_params_one, index_name="a")
|
||||
|
@ -4548,7 +4548,8 @@ class TestsearchDiskann(TestcaseBase):
|
|||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, ids = \
|
||||
self.init_collection_general(prefix, True, dim=dim, primary_field=ct.default_string_field_name, is_index=True)[0:4]
|
||||
self.init_collection_general(prefix, True, dim=dim, primary_field=ct.default_string_field_name,
|
||||
is_index=False)[0:4]
|
||||
# 2. create index
|
||||
default_index = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}}
|
||||
collection_w.create_index(ct.default_float_vec_field_name, default_index)
|
||||
|
|
Loading…
Reference in New Issue