#random

Python Error: Misusing `id` as a Query Field

TLDR Alberto was having trouble querying based on 'id' in their Python code. Kishore Nallan clarified that 'id' is a special field and cannot be queried by it just yet.

Powered by Struct AI
Oct 28, 2023 (1 month ago)
Alberto
Photo of md5-f7dd019896dcb8aafdeb865ce17569b2
Alberto
09:22 PM
Hello every one.
Could please somebody help me with this error! It is drving me crazy, I cannot find what is wrong.
I'm using python3.10.11

This is my schema

my_schema = {
'name': 'oias',
'fields': [
{'name': 'number', 'type': 'int32'},
{'name': 'id', 'type': 'string'},
{'name': 'name', 'type': 'string'},
]
]

This is an example of my jsonl

{"number": 1, "name": "name_1", "id": "A000001"}
{"number": 2, "name": "name_2", "id": "A000002"}
{"number": 3, "name": "name_3", "id": "A000003"}
{"number": 4, "name": "name_4", "id": "A000004"}

When I do the search:

search_parameters = {
'q': A000002
'query_by': 'id',
"exhaustive_search": 'true',
}

client.collections['oias'].documents.search(search_parameters)

I get this error:

RequestMalformed: [Errno 400] Cannot use id as a query by field.

PLEASE, HELP!
I would really appreciate any comment
Oct 29, 2023 (1 month ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:24 AM
The id is a special field which is actually ignored in the schema. You can filter on it, but cannot yet query on it (we've plans to allow this in future). You have to index id as another regular field if you wish to do this.