Skip to content
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

The "Data Query" cannot apply numeric key for JSON field as filter expression #335

Closed
yhmo opened this issue Dec 12, 2023 · 1 comment · Fixed by #341
Closed

The "Data Query" cannot apply numeric key for JSON field as filter expression #335

yhmo opened this issue Dec 12, 2023 · 1 comment · Fixed by #341

Comments

@yhmo
Copy link

yhmo commented Dec 12, 2023

Describe the bug:
The "Data Query" cannot apply numeric key for JSON field as filter expression

Steps to reproduce:

  1. create a collection with a JSON field
  2. insert some rows with numeric key in the JSON field
import random
import time

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

connections.connect(host='localhost', port='19530')
print(utility.get_server_version())

collection_name = "test"
dim = 1536
metric_type = "L2"

# create collection
id_field = FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=False,)
vector_field = FieldSchema(name="vector", dtype = DataType.FLOAT_VECTOR, dim=dim)
name_field = FieldSchema(name="name", dtype = DataType.JSON)

schema = CollectionSchema(fields=[id_field, vector_field, name_field])

if utility.has_collection(collection_name):
    utility.drop_collection(collection_name)

collection = Collection(name=collection_name, schema=schema)
print(f"Collection '{collection_name}' created")

for i in range(10000):
    collection.insert({"id": i, "vector": [random.random() for _ in range(dim)], "name": {f"{i}": True, f"{i+1}": False}})
    if i%100==0:
        print("insert", i)

collection.flush()
print(collection.num_entities)

index_params = {
    'metric_type': metric_type,
    'index_type': "FLAT",
    'params': {},
}
collection.create_index(field_name="vector", index_params=index_params)
print("index created")

collection.load()
print("collection loaded")

print("query...")
collection = Collection(collection_name)
res = collection.query(expr='name["222"] == True', consistency_level="Strong", output_fields=["name"])
for r in res:
    print(r)
  1. in Attu, use Data Query to filter by the numeric key

Attu version:
Milvus v2.3.3
Attu v2.3.4

Attu version:

@yhmo
Copy link
Author

yhmo commented Dec 12, 2023

Screenshot from 2023-12-12 14-21-05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant