Created
September 22, 2014 22:40
-
-
Save maddyblue/796eb2ad5b9712ea992e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
func main() { | |
buf := bytes.NewBufferString(JJ) | |
resp, err := http.Post("http://ny-search01.ds.stackexchange.com:9200/1/post/_search", "application/json", buf) | |
if err != nil { | |
log.Fatal(1, err) | |
} | |
b, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
log.Fatal(2, err) | |
} | |
buf = new(bytes.Buffer) | |
if err := json.Indent(buf, b, "", " "); err != nil { | |
fmt.Println(string(b)) | |
} | |
fmt.Println(buf.String()) | |
} | |
const JJ = `{ | |
"from": 0, | |
"size": 100, | |
"query": { | |
"custom_score": { | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"wildcard": { | |
"urls": "*play.golang.org/p/*" | |
} | |
} | |
] | |
} | |
}, | |
"params": { | |
"factor": 0.005 | |
}, | |
"script": "_score * (doc['score'].value > 0 ? 1+doc['score'].value*factor : 1)" | |
} | |
}, | |
"filter": { | |
"term": { | |
"isDeleted": false | |
} | |
} | |
}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment