Resolving Auto-Schema and Configuration Issues in Typesense
TLDR Narayan was struggling with auto-schema and configuration issues in Typesense. With the help of Kishore Nallan, they understood and solved the problems by adding 'optional' to all nested fields. They will find a way to handle 'None'.
1
Sep 22, 2023 (2 months ago)
Narayan
03:05 AMobject
type field is also set to not be indexed. If I specify a schema I would expect that auto schema does not kick in😅Kishore Nallan
03:08 AMNarayan
05:03 AMNarayan
05:05 AMSchema
{
"name": "Company",
"enable_nested_fields": True,
"fields": [
{
"name": "id",
"type": "string"
},
{
"name": "persons",
"type": "object[]",
"index": False,
"optional": True,
},
{
"name": "persons.id",
"type": "int64[]"
},
{
"name": "persons.addresses.zip",
"type": "string[]"
}
]
}
When I try to import the following docs typesense complain:
[
{
"id": "131415",
"persons": []
},
{
"id": "789",
"persons": [
{
"id": 1,
"addresses": [{"zip": None}]
},
{
"id": 2,
"addresses": [{"zip": "11112"}]
},
{
"id": 3,
"addresses": [{"zip": "11113"}]
}
]
},{
"id": "1011112",
"persons": [
{
"id": 4,
"addresses": [{"zip": "11111"}]
},
{
"id": 5,
"addresses": [{"zip": "11112"}]
},
{
"id": 6,
"addresses": [{"zip": "11115"}]
}
]
}
]
The errors:
[{'code': 400, 'document': '{"id": "131415", "persons": []}', 'error': 'Field `persons.addresses.zip` has been declared in the schema, but is not found in the document.', 'success': False}]
Narayan
05:06 AMpersons.id
and persons.addresses.zip
as optional
but it still complains for the first two docs. Only when I provide all the necessary fields and none of them are None
, like in the 3rd case, it works.Kishore Nallan
05:08 AMNarayan
05:10 AMKishore Nallan
05:10 AM {
"id": "131415",
"persons": []
},
Narayan
05:12 AMpersons
as optional
. Should I instead just use {"id":131415}
when there are no persons
?Narayan
05:12 AM{"id":131415}
this too does not work and still raises the same errorKishore Nallan
05:13 AM"addresses": [{"zip": None}]
Narayan
05:13 AMKishore Nallan
05:13 AMpersons
as optional but have explicit child reference which is not marked as optional, so the explicit child field paths get prirority.Kishore Nallan
05:14 AM"optional": True,
to the child fieldsKishore Nallan
05:15 AMNone
Narayan
05:16 AMNarayan
05:21 AMoptional
to all nested fields helped. thanks! I’ll figure out how to deal with None
1
Typesense
Indexed 3015 threads (79% resolved)
Similar Threads
Issues with Schema Creation and Nested Fields
Sean encountered a problem with schema creation involving auto nested fields. Kishore Nallan suggested checking the API response for errors and adding problematic fields to the schema as optional. Sean confirmed the advice.
Trouble in Implementing Deeply Nested Search
Anirudh is struggling to implement a two-level nested search. Jason asked for some specific examples to study the issue. Anirudh provided some material, realizing that adding top fields helped but might over-index. Jason then suggested reporting this issue on GitHub.
Defining Nested JSON Schema for Querying
Greg struggled in defining a schema for querying a JSON object with nested fields. Jason offered solutions, with the final resolution involving the use of "object" as a field type for the contributors in the schema.
Cold Start Problem with Dynamic Collections
Adrian reported cold start issues with dynamic collections. Jason suggested using wildcard `*` for query_by parameters, upgrading to `0.25.0.rc34`, and clarified conventions. Adrian's issues were resolved but they reported a limitation that will potentially be addressed.
Troubleshooting Query Error with Optional Nested Objects
Jordan encountered an error while querying optional nested objects. Jason suggested ensuring at least one document has the field or defining fields explicitly in the schema.