This message was deleted.
# community-help
s
This message was deleted.
k
Yeah the new highlight structure overlays on the original field structure which means that nested fields can have an arbitrary number of levels.
j
Yeah the new highlight type seems like it'd be hard to represent in Go as-is due to the fact you can have object fields.
k
Wondering if there is a way to maybe make the client accept some type for desererialization
j
It seems like you can end up with any of the following for a highlight:
Copy code
{ "matched_tokens": [], ... }
Copy code
[
  { "matched_tokens": [], ... },
  { "matched_tokens": [], ... },
  ...
]
Copy code
{
  "key1": { "matched_tokens": [], ... },
  "key2": { "matched_tokens": [], ... },
  ...
}
Oh you can have
[]object
too 🤔 certainly makes it hard to represent in OpenAPI or in most languages I'd imagine.
k
Unfortunately what's easy for dynamically typed languages like JS is doubly difficult in typed. This was very convenient for JS.
j
I guess when deserialising I could extensively list all of the fields and their types, not ideal though as it'd be nice if there was some generic representation for highlight data.
k
People wanted to be able to access the nested structure directly, which is why we ended up with this approach.
j
Yeah it makes sense for JS, much more convenient
j
Btw, in Typescript, there's a concept of generics where we can allow a user to define the types for their docs and pass that into the Typesense Typescript library and that gets used internally to also represent the highlight structure, by just replacing the leaf matched field to the highlight structure (not sure if we've implemented this yet, but it should be theoretically possible. But we've implemented this pattern to represent the hits[].document field for eg)