milvus-io/milvus
GitHub で見る[Bug]: not supported to do arithmetic operations between multiple fields
Open
#39,629 opened on 2025年2月3日
good first issuekind/enhancementkind/feature
説明
Is there an existing issue for this?
- I have searched the existing issues
Environment
- Milvus version: 2.5.4
- Deployment mode(standalone or cluster): standalone
- SDK version(e.g. pymilvus v2.0.0rc2): pymilvus 2.5.4
- OS(Ubuntu or CentOS): Ubuntu
Current Behavior
The basic operators docs contain examples of multi field arithmetic operations but it fails with the following error while testing on my local machine running milvus on docker:
pymilvus.exceptions.MilvusException: <MilvusException: (code=1100, message=failed to create query plan: cannot parse expression: price * quantity > 100, error: not supported to do arithmetic operations between multiple fields: invalid parameter)>
Multi field arithmetic operations are something I wish to use so would appreciate some help here. Is this a bug or something I've misconfigured?
Expected Behavior
Should parse the filter and execute the query as suggested in the linked docs
Steps To Reproduce
Run milvus on docker
curl -sfL https://raw.githubusercontent.com/milvus-io/milvus/master/scripts/standalone_embed.sh -o standalone_embed.sh
bash standalone_embed.sh start
Python script to reproduce
from pymilvus import MilvusClient, DataType
import random
import numpy as np
client = MilvusClient(uri="http://localhost:19530")
# Create schema
schema = MilvusClient.create_schema(
auto_id=True,
enable_dynamic_field=True,
)
schema.add_field(field_name="id", datatype=DataType.INT64, is_primary=True)
schema.add_field(field_name="price", datatype=DataType.INT64)
schema.add_field(field_name="quantity", datatype=DataType.INT64)
schema.add_field(field_name="embedding", datatype=DataType.FLOAT_VECTOR, dim=5)
# Create index
index_params = client.prepare_index_params()
index_params.add_index(field_name="embedding",
index_type="AUTOINDEX",
metric_type="COSINE")
# Create collection
collection_name = "product"
client.create_collection(collection_name=collection_name,
schema=schema,
index_params=index_params)
# Insert sample data
num_samples = 10
data = [{
"price": random.randint(1, 1000),
"quantity": random.randint(1, 50),
"embedding": np.random.rand(5).tolist()
} for _ in range(num_samples)]
client.insert(collection_name, data)
# Load collection
client.load_collection(collection_name)
# Query
expr = "price * quantity > 100"
results = client.query(collection_name,
expr,
output_fields=["price", "quantity"])
for result in results:
print(result)
Milvus Log
No response
Anything else?
No response