Skip to content

Instantly share code, notes, and snippets.

View quoeamaster's full-sized avatar

Q3Master quoeamaster

View GitHub Profile
// create client / http-request
if response, err := http.Get(fmt.Sprintf("%v/help", pTestServer.URL)); err != nil {
t.Errorf("failed to [/help] %v", err)
} else {
bData, _ := ioutil.ReadAll(response.Body)
line := string(bData)
t.Logf("[deb] help -> %v\n", line)
if strings.Contains(line, "help is under-development") {
t.Logf("- cool~ help is NORMAL\n")
} else {
pServer := http.NewServeMux()
// add handler(s)
pServer.HandleFunc("/help", func(w http.ResponseWriter, r *http.Request) {
bResponse, _ := json.Marshal(`{
"message": "help is under-development..."
}`)
w.WriteHeader(http.StatusOK)
w.Write(bResponse)
})
pServer.HandleFunc("/stats", func(w http.ResponseWriter, r *http.Request) {
PUT _cluster/settings
{
"persistent": {
"ingest": {
"geoip": {
"downloader": {
"enabled": "true"
}
}
}
@quoeamaster
quoeamaster / geoip_002.json
Created September 10, 2022 06:29
geoip_002.json
# check the database file availability
GET _ingest/geoip/stats
# ... results
{
"stats" : {
"successful_downloads" : 0,
"failed_downloads" : 0,
"total_download_time" : 0,
"databases_count" : 0,
@quoeamaster
quoeamaster / geoip_001.json
Created September 10, 2022 06:25
geoip_001.json
POST _ingest/pipeline/_simulate
{
"pipeline": {
"processors": [
{
"geoip": {
"field": "location"
}
}
]
@quoeamaster
quoeamaster / geoip_00
Created September 10, 2022 06:19
geoip_00.json
"geoip" : {
"continent_name" : "North America",
"country_name" : "United States",
"location" : {
"lon" : -97.822,
"lat" : 37.751
},
"country_iso_code" : "US"
}
GET courses-03/_search?filter_path=hits.hits._source,hits.hits._score,hits.hits.highlight
{
"query": {
"match": {
"comments.email": "donna.liselot@uni.gov"
}
},
"highlight": {
"fields": {
"comments.email": {}
POST courses-03/_bulk
{"index":{"_id":"A123"}}
{"comments":"if you think the course is nice and wanna comment, please send an email to -> donna.karen@uni.gov or jojo.star.crusade@uni.gov . Thx~"}
{"index":{"_id":"b1234"}}
{"comments":"Shout out to the great instructors donnie.yun@uni.gov and blah@uni.gov.uk"}
{"index":{"_id":"cy7L"}}
{"comments":"welcome donna.liselot@uni.gov to join the training team"}
/* no results */
GET courses-03/_search
PUT courses-03/
{
"settings": {
"analysis": {
"char_filter": {
"email_dot_replacer": {
"type": "mapping",
"mappings": [
". => -"
]
PUT courses-02/_doc/Abc123
{
"instructors": "donna.karen@uni.gov,jojo.star.crusade@uni.gov",
"course": {
"name": "Introduction to Economics",
"medium": "skype"
}
}
GET courses-02/_search
{