milvus-io / milvus

A cloud-native vector database, storage for next generation AI applications
https://milvus.io
Apache License 2.0
29.53k stars 2.83k forks source link

[Bug]: Recreate another index failed after drop one index before if the index was created with index name, reporting "index already exist, but parameters are inconsistent" #19345

Closed binbinlv closed 1 year ago

binbinlv commented 2 years ago

Is there an existing issue for this?

Environment

- Milvus version: master latest
- Deployment mode(standalone or cluster):both
- SDK version(e.g. pymilvus v2.0.0rc2):2.2.0.dev32
- OS(Ubuntu or CentOS): 
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

Recreate another index failed after drop one index before if the index was created with index name and reporting "index already exist, but parameters are inconsistent"

Expected Behavior

Recreate index successfully after index drop

Steps To Reproduce

from pymilvus import CollectionSchema, FieldSchema
from pymilvus import Collection
from pymilvus import connections
from pymilvus import DataType
from pymilvus import Partition
from pymilvus import utility

connections.connect(host="***", port="19530")

dim = 128
int64_field = FieldSchema(name="int64", dtype=DataType.INT64, is_primary=True)
float_field = FieldSchema(name="float", dtype=DataType.FLOAT)
bool_field = FieldSchema(name="bool", dtype=DataType.BOOL)
string_field = FieldSchema(name="string", dtype=DataType.VARCHAR, max_length=65535)
float_vector = FieldSchema(name="float_vector", dtype=DataType.FLOAT_VECTOR, dim=dim)
schema = CollectionSchema(fields=[int64_field, float_field, bool_field, float_vector])

collection = Collection("test_search_collection_binbin_2_0003", schema=schema)
import numpy as np
import random
import time

print("start inserting")
nb =50000
vectors = [[random.random() for _ in range(dim)] for _ in range(nb)]
res = collection.insert([[i for i in range(nb)], [np.float32(i) for i in range(nb)], [np.bool(i) for i in range(nb)], vectors])
t0 = time.time()
result = collection.num_entities
tt = time.time() - t0
print(result)
print(tt*1000)
index_param = {"index_type": "IVF_FLAT", "metric_type": "IP", "params": {"nlist": 100}}
collection.create_index("float_vector", index_param, index_name="index_name_0")
collection.load()
print("start searching")
nq = 2
limit = 50
default_search_params = {"metric_type": "IP", "params": {"nprobe": 10}}
res = collection.search(vectors[:nq], "float_vector", default_search_params, limit, "int64 >= 0")
print(res[0].ids)
print("start drop index")
collection.drop_index()
print("Dropped index")
collection.release()
index_param = {"index_type": "HNSW", "metric_type": "IP", "params": {'M': 32, 'efConstruction': 256}}
collection.create_index("float_vector", index_param, index_name="index_name_1")

Milvus Log

Please reproduce using the above script, thanks

Anything else?

No response

binbinlv commented 2 years ago

It is good if the index was created without specifying index name in the above script: collection.create_index("float_vector", index_param)

yanliang567 commented 2 years ago

/assign @xiaofan-luan /unassign

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Reopen the issue with /reopen.