Skip to content

Instantly share code, notes, and snippets.

View yinchunxiang's full-sized avatar
💭
coding

yinchunxiang yinchunxiang

💭
coding
View GitHub Profile
# match
curl -XPOST --user superuser:Adm1n 'http://localhost:9200/estest/table1/_search?pretty' -d '
{
"query" : {
"match" : {
"sex" : "term1 term2"
}
}
}'
curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"query": {
"filtered": {
"query": { "match_all": {} },
"filter": {
"range": {
"balance": {
"gte": 20000,
"lte": 30000
"_source": { "include": "", "exclude":""}
# SELECT COUNT(*) from bank GROUP BY state ORDER BY COUNT(*) DESC
curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"size": 0,
"aggs": {
"group_by_state": {
"terms": {
"field": "state"
}
Can be used without specifying an index against one of the many built in analyzers:
curl -XGET 'localhost:9200/_analyze?analyzer=standard' -d 'this is a test'
Or by building a custom transient analyzer out of tokenizers, token filters and char filters. Token filters can use the shorter filters parameter name:
curl -XGET 'localhost:9200/_analyze?tokenizer=keyword&filters=lowercase' -d 'this is a test'
curl -XGET 'localhost:9200/_analyze?tokenizer=keyword&token_filters=lowercase&char_filters=html_strip' -d 'this is a <b>test</b>'
It can also run against a specific index:
@yinchunxiang
yinchunxiang / disable_allocation
Created July 23, 2014 13:17
让Elasticsearch集群不做数据迁移
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.disable_allocation": true}}'
@yinchunxiang
yinchunxiang / ThreadPool.cc
Created January 10, 2016 14:58
C++ ThreadPool
class ThreadPool {
public:
ThreadPool(int num_threads) : stop_(0) {
for (int i = 0; i < num_threads; ++i) {
threads_.push_back(std::thread(&ThreadPool::run, this));
}
}
void AddTask(const std::function<void()> &task) {
{
std::unique_lock<std::mutex> lock(mutex_);
map "ctrl+f" scrollFullPageDown
map "ctrl+b" scrollFullPageUp
func trace() {
pc := make([]uintptr, 10) // at least 1 entry needed
runtime.Callers(2, pc)
f := runtime.FuncForPC(pc[0])
file, line := f.FileLine(pc[0])
fmt.Printf("%s:%d %s\n", file, line, f.Name())
}
@yinchunxiang
yinchunxiang / chunked_request.py
Created February 8, 2017 11:22
send chunked http request by python
import httplib
import time
chunk1 = "custname=bob&custtel=11111&custemail=bob%40email.com&si"
chunk2 = "ze=medium&topping=bacon&delivery=11%3A00&comments=if+you%27re+late+we+get+it+free"
if __name__ == "__main__":
#conn = httplib.HTTPConnection('httpbin.org')
#conn = httplib.HTTPConnection('requestb.in')
conn = httplib.HTTPConnection('ros.roobo.net')