This site have an example of elasticsearch query in go:
https://github.com/mattbaird/elastigo
The example is this:
A search using raw json string
searchJson := `{
"query" : {
"term" : { "user" : "kimchy" }
}
}`
out, err := core.SearchRequest(true, "twitter", "tweet", searchJson, "")
if len(out.Hits.Hits) == 1 {
fmt.Println(string(out.Hits.Hits[0].Source))
}
But i need something like this:
A varible inside a raw json string
term := "my search term"
searchJson := `{
"size" : "size",
"query" : {
"match" : {
"_all" : {
"query" : term,
"operator" : "and"
}
}
},
"sort" : [{
"name" : {
"order" : "asc",
"mode" : "avg"
}
}]
}`
How can i put a varible term inside a raw json string?
Is posible put a varible inside a raw json string?