Resolving Error with Hash Objects in Typesense
TLDR V had trouble with hash object fields not showing in a Typesense schema. Kishore Nallan advised enabling nested fields in the schema creation code.
Dec 02, 2022 (13 months ago)
V
12:27 PMi facing issue with hash object
hash object is showing in the documents but not showing field name in the schema so when i performing search it throw an error like data field not exist in the schema
what i am doing wrong?
Kishore Nallan
12:35 PMV
12:44 PMKishore Nallan
12:45 PMV
01:11 PMTypesense::Base.new.client.collections['listings'].documents.search({
q: query, query_by:'address.name',
filter_by: [].join(' && ')
})
when i hit above query it give me an error as show in image
V
01:12 PMKishore Nallan
01:13 PMaddress
an object field? If so you should enable nested field at the collection level with this option:"enable_nested_fields": true
V
01:17 PMso when i insert data in the typesense
it does not created new field with hash object (address)
V
01:20 PMKishore Nallan
01:26 PMV
01:29 PMaddress_schema =
{
'name' => 'address',
'fields' => [
{ 'name' => '.*', 'type' => 'auto' }
]
}
Typesense::Base.new.client.collections.create(address_schema)
Kishore Nallan
01:30 PM{
'name' => 'address',
'enable_nested_fields' => True,
'fields' => [
{ 'name' => '.*', 'type' => 'auto' }
]
}
Kishore Nallan
01:30 PMenable_nested_fields
-> the object field won't be searchable.V
01:34 PMlet me try.
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.
Updating Collection Schema and Querying Unspecified Fields in Typesense
Stefan asked about updating a collection schema. Kishore Nallan stated it's not currently possible but suggested automatic schema detection in version 0.20. Rishabh sought a workaround and Jason suggested creating a new collection with a new schema and re-indexing the data. Rishabh also asked about defining custom field IDs which Jason confirmed is not possible with Typesense.
Fixing "bad json" error in Typesense 0.24
Adam experiences "bad json" error when creating collections in Typesense 0.24. Jason identifies a typo in the docs causing the error and helps troubleshoot additional errors.
Using Typesense to Query by Custom Column Key Value
Sandip asked how to use Typesense to perform unique key searches in different organizations. Kishore Nallan suggested creating an 'object' field for varying keys. After a clarification, Sandip expressed satisfaction with the advice.
Accessing Nested Objects Using `query_by` in Typesense
Emma wanted to query nested objects using `query_by`. Kishore Nallan suggested using `title.*` pattern and ensuring `enable_nested_fields` is set to true.