Sorting Nested Fields in Schema Declaration
TLDR Ibrahim inquired how to sort by a nested object field 'name' in a schema. Jason suggested keeping only the 'product.name' part in the schema to achieve the sorting.
1
Nov 14, 2023 (2 weeks ago)
Ibrahim
02:46 AMI have a quick question, and would love some help.
So in one of my schemas, I am declaring an object field. Inside the object field, I have a field called 'name'
I want to be able to use
'sort_by'
to sort by that name field.When I declare my schema like this, it works fine
{
'name': 'product',
'type': 'auto',
},
{
'name': 'product.name',
'type': 'string',
'sort':True,
},
However, this doesn't seem to work and get a 'not a sortable field' error when I try to sort by 'product.name'
{
'name': 'product',
'type': 'auto',
'fields:[
{
'name': 'product.name',
'type': 'string',
'sort':True,
},
]
},
Is my first approach correct, or is there a way to make the second approach work?
Jason
05:27 AMproduct.name
, then just having this in the schema would suffice:{
'name': 'product.name',
'type': 'string',
'sort':True,
},
1
Typesense
Indexed 3011 threads (79% resolved)
Similar Threads
Discussion on High-cardinality Keys and Auto-schema Generation
Jack expressed concern over high cardinality keys resulting in extra fields in the collection. Jason clarified it's not an extra field but a transformation for matching values. Kishore Nallan assured high number of discovered fields is not an issue and promised to address schema creation for non-indexed objects.
Querying and Highlighting Nested Objects in Json
Patrick sought help on retrieving more information about highlighted nested objects in a JSON document. Aadarsh suggested a solution but the conversation became complicated due to schema errors identified by Jason.
Counting Facets within a Nested Object using Filters
Narayan asked how to get facet counts in a nested object, with filtering, and whether you can facet by an object. Jason suggested using `filter_by` and shared new features supporting this.