Skip to content

[Bug]: <MilvusException: (code=1100, message=only IP is the supported metric type for sparse index: invalid parameter[expected=valid index params][actual=invalid index params])> #2723

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

Open
1 task done
369699269 opened this issue Apr 9, 2025 · 2 comments
Labels
kind/question A question to answer

Comments

@369699269
Copy link

369699269 commented Apr 9, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

参考这篇文档的 collection构建方法,https://milvus.io/docs/zh/multi-vector-search.md

python 版本 3.11,pymilvus版本 2.5.5,milvus 服务端版本 v2.4.10

下面是我的code:

def create_collection():
milvus_client = MilvusClient(
uri=settings.AIOPS_MILVUS_DB_URL,
user=settings.AIOPS_MILVUS_DB_USER,
password=settings.AIOPS_MILVUS_DB_PASSWORD,
db_name=settings.AIOPS_MILVUS_DB_NAME
)
collection_name = "aiops_hybrid"
has_collection = milvus_client.has_collection(collection_name, timeout=5)
if has_collection:
print("⚠️ An existing collection was found and is being deleted...")
milvus_client.drop_collection(collection_name)
print("✅ Old collection deleted!")

# create schema
schema = milvus_client.create_schema()
schema.add_field("pk", DataType.INT64, is_primary=True, auto_id=True)
schema.add_field("text", DataType.VARCHAR, max_length=65535, enable_analyzer=True)
schema.add_field("dense_vector", DataType.FLOAT_VECTOR, dim=1536)
schema.add_field("sparse_vector", DataType.SPARSE_FLOAT_VECTOR)
schema.add_field("id", DataType.VARCHAR, max_length=512)
schema.add_field("title", DataType.VARCHAR, max_length=512)
schema.add_field("url", DataType.VARCHAR, max_length=512)
schema.add_field("chunk_index", DataType.INT64)

bm25_function = Function(
    name="bm25_fn",
    input_field_names=["text"],
    output_field_names=["sparse_vector"],
    function_type=FunctionType.BM25,
)
schema.add_function(bm25_function)
# create index
index_params = milvus_client.prepare_index_params()
index_params.add_index(
    field_name="dense_vector",
    index_name="dense_index",
    index_type="IVF_FLAT",
    metric_type="IP",
    params={"nlist": 128},
)
index_params.add_index(
    field_name="sparse_vector",
    index_name="sparse_index",
    index_type="SPARSE_INVERTED_INDEX",
    metric_type="BM25",
    params={"bm25_k1": 1.2, "bm25_b": 0.75},
)
milvus_client.create_collection(collection_name, schema=schema, index_params=index_params,
                                consistency_level="Strong")
print(f"create collection successfully!")

执行这个方法的时候报错

2025-04-09 12:27:52,312 [ERROR][handler]: RPC error: [create_index], <MilvusException: (code=1100, message=only IP is the supported metric type for sparse index: invalid parameter[expected=valid index params][actual=invalid index params])>, <Time:{'RPC start': '2025-04-09 12:27:51.960388', 'RPC error': '2025-04-09 12:27:52.312790'}> (decorators.py:140)
2025-04-09 12:27:52,313 [ERROR][_create_index]: Failed to create an index on collection: aiops_hybrid (milvus_client.py:183)
Traceback (most recent call last):
File "C:\Code\aiops\insert_milvus_multi.py", line 123, in
create_collection()
File "C:\Code\aiops\insert_milvus_multi.py", line 60, in create_collection
milvus_client.create_collection(collection_name, schema=schema, index_params=index_params,
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\milvus_client\milvus_client.py", line 99, in create_collection
return self._create_collection_with_schema(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\milvus_client\milvus_client.py", line 899, in _create_collection_with_schema
self.create_index(collection_name, index_params, timeout=timeout)
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\milvus_client\milvus_client.py", line 162, in create_index
self._create_index(collection_name, index_param, timeout=timeout, **kwargs)
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\milvus_client\milvus_client.py", line 184, in _create_index
raise ex from ex
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\milvus_client\milvus_client.py", line 173, in _create_index
conn.create_index(
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\decorators.py", line 141, in handler
raise e from e
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\decorators.py", line 137, in handler
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\decorators.py", line 176, in handler
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\decorators.py", line 116, in handler
raise e from e
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\decorators.py", line 86, in handler
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\client\grpc_handler.py", line 1083, in create_index
check_status(status)
File "C:\Code\aiops.venv\Lib\site-packages\pymilvus\client\utils.py", line 64, in check_status
raise MilvusException(status.code, status.reason, status.error_code)
pymilvus.exceptions.MilvusException: <MilvusException: (code=1100, message=only IP is the supported metric type for sparse index: invalid parameter[expected=valid index params][actual=invalid index params])>

Expected Behavior

No response

Steps/Code To Reproduce behavior

Environment details

- Hardware/Softward conditions (OS, CPU, GPU, Memory):
- Method of installation (Docker, or from source):
- Milvus version (v0.3.1, or v0.4.0):
- Milvus configuration (Settings you made in `server_config.yaml`):

Anything else?

No response

@369699269 369699269 added the kind/bug Something isn't working label Apr 9, 2025
@XuanYang-cn
Copy link
Contributor

This is a bug reported from Milvus, I'm looking into it

@XuanYang-cn
Copy link
Contributor

@369699269 FullText search in introduced at Milvus 2.5.0, Please upgrade your Milvus to the latest 2.5.x and try again.

@XuanYang-cn XuanYang-cn added kind/question A question to answer and removed kind/bug Something isn't working labels Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question A question to answer
Projects
None yet
Development

No branches or pull requests

2 participants