Cannot get prefix search to work on a scalar text field #35531
-
I cannot get prefix search to work on a scalar field. I can however get infix search to work which suggests that my field is not properly tokenized. ENV: Standalone Milvus 2.4.8 on Ubuntu 22.04 Here is my schema:
The field of interest is 'channels'. The channels field can look like this: When I search it the filter looks like this (but it does not work): The following infix search works: And the following prefix search works but only for the first token in the channels field: What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I think this is expected we don't do token split so only 48d302b1963841c39790fecf56b91ddc% or %c8a80b710e455460ae8b2399f5adfef5% will match your expression. I think the better way is to split channel into array and use contains in your operation |
Beta Was this translation helpful? Give feedback.
-
Array field might be the proper solution. Define the "channels" as Array type field, you can use ARRAY_CONTAINS/ARRAY_CONTAINS_ANY/ARRAY_CONTAINS_ALL to filter its elements. An example: from pymilvus import ( client = MilvusClient(uri="http://localhost:19530") collection_name = "AAA" schema = client.create_schema(enable_dynamic_field=False) index_params = client.prepare_index_params() data = [ def search(filter: str): search(filter='ARRAY_CONTAINS(channels, "c8a80b710e455460ae8b2399f5adfef5")') |
Beta Was this translation helpful? Give feedback.
Array field might be the proper solution.
Define the "channels" as Array type field, you can use ARRAY_CONTAINS/ARRAY_CONTAINS_ANY/ARRAY_CONTAINS_ALL to filter its elements.
An example:
**
import random
from pymilvus import (
MilvusClient, DataType,
)
client = MilvusClient(uri="http://localhost:19530")
print(client.list_collections())
collection_name = "AAA"
schema = client.create_schema(enable_dynamic_field=False)
schema.add_field("id", DataType.VARCHAR, is_primary=True, auto_id=False, max_length=65535)
schema.add_field("vector", DataType.FLOAT_VECTOR, dim=128)
schema.add_field("tag", DataType.VARCHAR, max_length=65535, is_partition_key=True)
schema.add_field(field_name="channels", datat…