You might be interested to take a look at how we do it in the elasticsearch
client we wrote for one of our services:

https://godoc.org/gopkg.in/juju/charmstore.v5/elasticsearch

On Mon, 3 Dec 2018 at 15:27, 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" } } } } }
>
>
> 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.

Reply via email to