-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE]: Check if an index exists #1361
Comments
collection.has_index should be the API you are looking for |
Unfortunately, just having an attribute index causes it to respond with True. I think it grabs the first index it can without checking if its on the embedding field. |
This one should check for vector field and I guess it only cares about vector index unless you pass in indexname. |
connections.connect(host='localhost', port=19530)
fields = [
FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
FieldSchema(name="string1", dtype=DataType.VARCHAR, max_length=1000),
FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=DIMENSION),
]
schema = CollectionSchema(fields=fields)
if utility.has_collection("lol"):
utility.drop_collection("lol")
collection = Collection("lol", schema, consistency_level="Strong")
index_params = {
'metric_type':'L2',
'index_type':"HNSW",
'params':{'M': 8, 'efConstruction': 64}
}
collection.create_index('id')
print("has_index() call", collection.has_index())
try:
collection.load()
except MilvusException as e:
print(e.message) will print:
|
if you define the name of index, should be has_index('id')? |
Unfortunately that doesn't work either, the only argument for has_index is timeout, so it tries to timeout based on a str which throws an exception. |
/assign @czs007 |
how do we check the index of a collection? |
Hello, @filip-halt , this feature may be implemented in #1386 , feel free to give feedbacks if it didn't satisfy the requirements. |
/assign @filip-halt |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe.
At the current moment there is not fast way to check if an index exists on the vector in a collection.
In order to check if an index exists you first need to extract the embedding field name from the schema by iterating over all its fields looking for a dataype of FLOAT_VECTOR or BINARY_VECTOR. Then you must go through the indexes of the collection and check if the index.field_name matches the embedding field name.
The other route is to try to load() and catch the exception but that seems a bit hacky.
Describe the solution you'd like
collection.vector_indexed() returns true or false based on having an index built on the vector field.
Describe alternatives you've considered
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: