Creating Schema for Nested Objects in JSON
TLDR Greg asked about creating schemas for nested objects in JSON. Jason provided information about indexing nested fields in Typesense v0.24.0. PneuViz requested details about replacing the 'highlights' field with 'highlight' in the new version.
1
Sep 23, 2022 (15 months ago)
Greg
08:31 PM{
"contributors": {
"contributor1": {
"bio": "Some bio",
"firstName": "John",
"lastName": "Doe",
"type": "author"
},
"contributor2": {
"bio": "Another bio",
"firstName": "Jane",
"lastName": "Joe",
"type": "editor"
},
"contributor3": {
"bio": "An even better bio",
"firstName": "Billy",
"lastName": "Jean",
"type": "influencer"
}
}
}
Greg
08:31 PMGreg
08:33 PM{
"contributors": [{
"bio": "Some bio",
"firstName": "John",
"lastName": "Doe",
"type": "author"
},
{
"bio": "Another bio",
"firstName": "Jane",
"lastName": "Joe",
"type": "editor"
},
{
"bio": "An even better bio",
"firstName": "Billy",
"lastName": "Jean",
"type": "influencer"
}
]
}
Jason
08:35 PMIf you’re running 0.24.0, here’s how to index nested fields: https://github.com/typesense/typesense/issues/227#issuecomment-1211666924
Greg
08:38 PMJason
08:43 PM1
Oct 10, 2022 (14 months ago)
PneuViz
06:30 PMJason
08:21 PMhighlight
which will include highlights for all fields, including nested fields. There should still be a field called highlights
(plural) which lists all highlights for non-nested fields.Typesense
Indexed 3015 threads (79% resolved)
Similar Threads
Duplicate Highlight Keys in Search Results
Manish noticed two highlight keys in search results. Jason explained "highlight" is the newer key for nested fields, while "highlights" is for backward compatibility.
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.
Issues with Highlight Version in Typesense
Stefan reported issues with the new highlight version in Typesense. Kishore Nallan provided a temporary workaround and further fixed the issue with an updated build.
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.
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.