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
// 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 { |
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
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) { |
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
PUT _cluster/settings | |
{ | |
"persistent": { | |
"ingest": { | |
"geoip": { | |
"downloader": { | |
"enabled": "true" | |
} | |
} | |
} |
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
# check the database file availability | |
GET _ingest/geoip/stats | |
# ... results | |
{ | |
"stats" : { | |
"successful_downloads" : 0, | |
"failed_downloads" : 0, | |
"total_download_time" : 0, | |
"databases_count" : 0, |
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
POST _ingest/pipeline/_simulate | |
{ | |
"pipeline": { | |
"processors": [ | |
{ | |
"geoip": { | |
"field": "location" | |
} | |
} | |
] |
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
"geoip" : { | |
"continent_name" : "North America", | |
"country_name" : "United States", | |
"location" : { | |
"lon" : -97.822, | |
"lat" : 37.751 | |
}, | |
"country_iso_code" : "US" | |
} |
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
GET courses-03/_search?filter_path=hits.hits._source,hits.hits._score,hits.hits.highlight | |
{ | |
"query": { | |
"match": { | |
"comments.email": "[email protected]" | |
} | |
}, | |
"highlight": { | |
"fields": { | |
"comments.email": {} |
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
POST courses-03/_bulk | |
{"index":{"_id":"A123"}} | |
{"comments":"if you think the course is nice and wanna comment, please send an email to -> [email protected] or [email protected] . Thx~"} | |
{"index":{"_id":"b1234"}} | |
{"comments":"Shout out to the great instructors [email protected] and [email protected]"} | |
{"index":{"_id":"cy7L"}} | |
{"comments":"welcome [email protected] to join the training team"} | |
/* no results */ | |
GET courses-03/_search |
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
PUT courses-03/ | |
{ | |
"settings": { | |
"analysis": { | |
"char_filter": { | |
"email_dot_replacer": { | |
"type": "mapping", | |
"mappings": [ | |
". => -" | |
] |
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
PUT courses-02/_doc/Abc123 | |
{ | |
"instructors": "[email protected],[email protected]", | |
"course": { | |
"name": "Introduction to Economics", | |
"medium": "skype" | |
} | |
} | |
GET courses-02/_search | |
{ |
NewerOlder