Skip to content

Instantly share code, notes, and snippets.

@hectorgool
Created November 22, 2016 17:21
Show Gist options
  • Select an option

  • Save hectorgool/1b4dacb2fd4095fd778551fd684adf6d to your computer and use it in GitHub Desktop.

Select an option

Save hectorgool/1b4dacb2fd4095fd778551fd684adf6d to your computer and use it in GitHub Desktop.
query term
package main
/*
{
"query": {
"match": {
"_all": {
"operator": "and",
"query": "Rodolfo Guzman Huerta"
}
}
},
"size": 10,
"sort": [
{
"colonia": {
"mode": "avg",
"order": "asc"
}
}
]
}
*/
import (
j "github.com/ricardolonga/jsongo"
"fmt"
)
func main() {
term := "Rodolfo Guzman Huerta"
json := j.Object().
Put("size", 10).
Put("query", j.Object().
Put("match", j.Object().
Put("_all", j.Object().
Put("query", term).
Put("operator", "and")))).
Put("sort", j.Array().
Put(j.Object().
Put("colonia", j.Object().
Put("order", "asc").
Put("mode", "avg"))))
fmt.Println(json.Indent())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment