mysql - Best Practice to go from sphinx db to somewhat complex golang struct -
i trying convert sphinx query via mysql golang struct , having hard time. seems should common sort of problem, far i'm stuck converting map or parsing output myself. specifically, have schema in sphinx looks {source: {id:string, subid:string, campaigns:[]{campaignid:string, status:string}}}
i've tried using simple rows.scan doesn't me parse repeating field, unparsed string. in sphinx, key's aren't in quotation marks, json.unmarshal doesn't seem @ all. , using sqlx, i've tried build following struct
type campaignstatus struct { campaignid string status string } type source struct { id string subid string statusbycampaign []campaignstatus } type status struct { source } and passing in status struct row.scanstruct() , either "missing destination name source" error or if name source member in status, "sql: scan error on column index 0: unsupported scan, storing driver.value type []uint8 type *v1.source". full disclosure, sphinx schema has few other columns peers statusbycampaign, come after , don't care them in use case.
this seems has have been come across before, can't seem find solution outside of writing own parser, loath do.
i found out legacy system i'm working using asp.net library called servicestack serialize/deserialize sphinx db, , using it's own custom jsv format, author of servicestack optimized mix of json , csv, hasn't been adopted anywhere else far can tell.
so looks i'm going either rewrite library in go, or more change indexing algorithm use json.
Comments
Post a Comment