参考
一、测试
Must 里面的都得成立
should里面的成立一个即可,若should里面只有一个,那么就用这一个的条件
term 精确匹配,不会分词
match_phrase 精确匹配
会分词,一般是按照空格分
目标文档包含,分词后的所有词
文档彼此位于相同的位置
使用boost的场景,term、range、boost
Range gt、le 大于小于 y M w d h H m s
script脚本操作
//doc['price']
GET /mall/product/_search
{
"query": {
"script": {
"script": {
"inline": "doc['price'].value > params.num",
"params": {"num": 25}
}
}
}
}
//ctx._source
POST /mall/product/3/_update
{
"script": {
"inline": "ctx._source.price = params.num",
"params": {"num": 40}
}
}
PUT /lulog/doc/2
{
"log_size": 2
}
POST /lulog/doc/_search
{
"query": {
"match_all": {}
},
"script_fields": {
"total_size": {
"script": {
"inline": "int total=0;for(int i=0; i<doc['log_size'].length;i++){total += doc['log_size'][i];}return total"
}
}
}
}
POST /lulog/doc/_search
{
"query": {
"match_all": {}
},
"script_fields": {
"count": {
"script": {
"inline": "return doc['log_size'].value + 1"
}
}
}
}
聚合:
Metric统计,min、max、sum、avg、stats、extended_stats
Bucket分类,terms,range,date_range,histogram,date_histogram,filter过滤
Pipeline对bucket分类的进行统计,min_bucket,max_bucket,sum_bucket,avg_bucket,stats_bucket,extended_stats_bucket
Matrix计算两个数值型字段之间的关系
GET incall_daily-2020.04.24/doc/_search
{
"aggs": {
"asdjhasd": {
"matrix_stats": {
"fields": ["applause_count", "answer_count"]
}
}
}
}
{
"name": "applause_count", //字段名称