milvus-io / milvus

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

[Bug]: Search fails with filter expression contains underscore #38068

Open yhmo opened 4 days ago

yhmo commented 4 days ago

Is there an existing issue for this?

Environment

- Milvus version: 2.4.16
- Deployment mode(standalone or cluster):
- MQ type(rocksmq, pulsar or kafka):    
- SDK version(e.g. pymilvus v2.0.0rc2):
- OS(Ubuntu or CentOS): 
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

from pymilvus import (
    connections,
    FieldSchema, CollectionSchema, DataType,
    Collection,
    utility,
)
import random

HOST = '127.0.0.1'
PORT = '19530'

connections.connect(host=HOST, port=PORT)
print(utility.get_server_version())

collection_name = "AAA"
dim = 128

fields = [
    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=False),
    FieldSchema(name="vector", dtype=DataType.FLOAT_VECTOR, dim=dim),
    FieldSchema(name="var", dtype=DataType.VARCHAR, max_length=100),
    FieldSchema(name="var_array", dtype=DataType.ARRAY, element_type=DataType.VARCHAR, max_capacity=20, max_length=100),
]
schema = CollectionSchema(fields)

utility.drop_collection(collection_name)
collection = Collection(collection_name, schema)

collection.insert({"id": 1, "vector": [random.random() for _ in range(dim)], "var": "abc_1_9", "var_array": ["abc_1_0"]})
collection.insert({"id": 2, "vector": [random.random() for _ in range(dim)], "var": "abc_2_9", "var_array": ["abc_2_0", "abc_2_1", "abc_2_2"]})
collection.insert({"id": 3, "vector": [random.random() for _ in range(dim)], "var": "abc_3_9", "var_array": ["abc_3_5"]})

collection.flush()

collection.create_index("vector", {"index_type": "AUTOINDEX", "metric_type": "IP"})
collection.load()

res = collection.query(expr="var_array[0] like \"abc_2%\"", output_fields=["var_array"])
for r in res:
    print(r)

Got an error: pymilvus.exceptions.MilvusException: <MilvusException: (code=65535, message=fail to Query on QueryNode 1: worker(1) query failed: Operator::GetOutput failed for [Operator:FilterBits, plan node id: 0] : => unsupported operator type for unary expr: Match at /workspace/source/internal/core/src/exec/expression/UnaryExpr.cpp:319

Expected Behavior

No response

Steps To Reproduce

No response

Milvus Log

No response

Anything else?

No response

yanliang567 commented 4 days ago

/assign @xiaocai2333 /unassign

JsDove commented 3 days ago

/assign @JsDove