On Mon, Dec 3, 2018 at 8:27 AM Jeffrey Smith <jeffreysmith19...@gmail.com> wrote: > > I'm trying to set mapping in elastic search in go and want to generate > something like this. > > { "mappings": { "_doc": { "properties": { "title": { "type": "text", "store": > true }, "date": { "type": "date", "store": true }, "content": { "type": > "text" } } } } } >
Is this close to what you're trying to do: https://play.golang.org/p/wYOwf6wUai7 > > The _doc, title,date and content are all keys that will change depending on > what mapping I am trying to generate. > > I have a basic struct layout but cant work out how to generate the proper > JSON. > > type mappingData struct { > Mappings struct { > Doc struct { > Properties struct { > Elements []Fields > } `json:"properties"` > } `json:"_doc"` > } `json:"mappings"` > } > > > type Fields struct { > Type string `json:"type"` > Store bool `json:"store"` > } > > _doc will be from a string and I have a vector of structs that has different > fields in. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.