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.
Oct 28, 2023 (1 month ago)
Alberto
09:22 PMCould 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
02:24 AMid
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.Typesense
Indexed 3015 threads (79% resolved)
Similar Threads
Resolving 'Cannot use `id` as a query by field' error in Typesense
Alberto was encountering a 'Cannot use `id` as a query by field' error in Typesense. Jason clarified that the 'id' field is used internally and suggested duplicating data in a new field for searching.
Fixing Multiple Document Retrieval in Typesense
Phil needed an efficient way to retrieve multiple documents by id. Kishore Nallan proposed a solution available in a pre-release build. After some bug fixing regarding id matching by Jason and Kishore Nallan, Phil successfully tested the solution.
Sorting Results in Typesense and Handling Errors
Ramees asks about sorting results by distance in Typesense, entering a list of strings as a field, and resolving an error with `fields` format. Kishore Nallan assists with these issues and advises on storing timestamps and proper authentication.