Elasticsearch 权威指南(中文版)
https://es.xiaoleilu.com/
elasticsearch 官网 生产环节必看
https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html
一、建立索引:
例:
参数 ip namespace
建立车辆结构化数据索引
./common_vehicle5.5.sh localhost capability
建立车辆结构化数据索引
./vehiclePeer5.5.sh localhost capability
建立视频结构化车辆结构化索引
./trace_vehicle5.5.sh localhost capability
建立视频结构化行人结构化索引
./trace_person5.5.sh localhost capability
建立视频结构化骑车人结构化索引
./trace_bicycle5.5.sh localhost capability
二、简单优化
原则:时间分区,按月或按天(或周,小时,分钟),数据要设置routing值,避免聚合时多分片跨节点取数据。聚合的话,分区,分桶,分路由,合并segement,减少segement数量。Mapping 中字段,不需要分词的不分词,不需要索引的不索引(倒排索引,和正向索引),需要缓存的启用缓存,需要全球序列的启用全球序列,避免稀疏字段,避免字段过多,历史日志避免更新(尤其时定时优化过的索引),避免分词的字段过长,引起内存膨胀,参考(百度淘宝seo优化,title 标题,keyword 关键字,标签,descirption 描述 大多有字数限制,正文一定要用分词并且十分庞大的话,感觉应该基于内存索引库,或是分布式内存文件系统,或者知识库来处理,希望有大神指点下)
每晚的21:30
定时合并segment
30 21 * * * curl -XPOST "http://localhost:9200/*/_forcemerge?max_num_segments=1"
提示:es段需要定时优化,并且需要优化调参默认的参数配置满足不了要求(业务多是大批量数据实时聚合实现),分段比较多的时候搜索聚合慢,
需要在写入更新的同时段的数量不会太多,这样的话写入速度有影响,默认的参数段的段的数量偏多,
现在是一个月一个索引,
还有就是拆成一天一个索引后定时合并段,但是存在大量更新的情况时,segment段的数量还是会起来,从而影响检索速度
https://www.elastic.co/guide/cn/elasticsearch/guide/current/inside-a-shard.html
替代方案:drill +indexr 做数据仓库,大批量数据实时聚合走drill +indexr
因为支持sql,支持join,聚合有优化
CDH集群只需要安装drill组件,indexr只是类似lucence的数据格式
ElasticSearch 内存那点事
Elasticsearch全方面优化点
关于ES性能调优几件必须知道的事
segments merge 流程分析
通过这几篇文章
通过反复验证大致知道,测试数据单个索引(一个月的)记录数在1亿3000万大小位320G,预估生产为2.4亿 大小为590G
segement 数量 320G /5 =64
segement 数量 590G /5 =118
index.merge.policy.segments_per_tier : "24",
index.merge.policy.floor_segment: "26mb",
index.merge.policy.max_merged_segment: "5gb"
归并策略
归并线程是按照一定的运行策略来挑选 segment 进行归并的。主要有以下几条:
index.merge.policy.floor_segment 默认 2MB,小于这个大小的 segment,优先被归并。
index.merge.policy.max_merge_at_once 默认一次最多归并 10 个 segment
index.merge.policy.max_merge_at_once_explicit 默认 forcemerge 时一次最多归并 30 个 segment。
index.merge.policy.max_merged_segment 默认 5 GB,大于这个大小的 segment,不用参与归并。forcemerge 除外。
根据这段策略,其实我们也可以从另一个角度考虑如何减少 segment 归并的消耗以及提高响应的办法:加大 flush 间隔,尽量让每次新生成的 segment 本身大小就比较大
三、常用处理语句
//删除索引
curl -XDELETE "http://localhost:9200/vehicle*"
//批量删除数据
curl -XPOST "http://localhost:9200/vehicle*/_delete_by_query?conflicts=proceed" -d '
{
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"must_not": [],
"should": []
}
}
}
'
//批量修改
curl -XPOST "http://localhost:9200/vehicle*/_update_by_query?conflicts=proceed" -d '
{
"query": {
"bool": {
"must": {
"match_all": {}
}
}
},
"script": {
"inline": "ctx._source.plate_no =鄂SE7590_0",
"lang": "painless"
}
}'
四、数据入库
a1、新增过车数据 批量新增并更新
POST http://localhost:9200/_bulk
{ "update":{"_id":"194B9E1D57E04FD7BDB5A3B599CC6EC0","_routing":"鄂SE7590_0","_index":"capabilityvehicle6","_type":"vehicle19"}}
{"doc_as_upsert":true,"doc":{}}
a2、新增同行车数据 批量新增
POST http://localhost:9200/_bulk
{ "index":{"_routing":"鄂SX2016_0_豫QE1188_0","_index":"capability_peek6","_type":"vehicle"}}
{}
a3、新增目标车辆 批量新增
POST http://localhost:9200/_bulk
{ "update":{"_id":"2852","_routing":"deb184cbd0bc4f6fadea94a2d794682e","_index":"tracevehicle1","_type":"vehicle19"}}
{"doc_as_upsert":true,"doc":{}}
a4、新增视频结构化数据行人 批量新增
POST http://localhost:9200/_bulk
{ "index":{"_id":"27","_routing":"de8fdbb384ef46e7bc56bd68e09fbdba","_index":"person1","_type":"person19"}}
{}
a5、新增视频结构化数据骑车人 批量新增
POST http://localhost:9200/_bulk
{ "index":{"_id":"10","_routing":"b098cbe1eb684d4cbaaa428fa1f7b7fc","_index":"bicycle1","_type":"bicycle19"}}
{}
五、技战法
post http://localhost:9200/vehicle*/_search?request_cache=true
1、首次入城车
a1、全城搜索 直接根据落脚时间过滤出符合要求的,返回该车最新一条过车记录 ,可以排序
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"query_string": {
"query": "鄂A*",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"range": {
"residencetime": {
"gte": 1440
}
}
}
]
}
}
}
},
"_source": {
"includes": [
"*"
],
"excludes": [
"track.*"
]
},
"sort": {
"pass_time": {
"order": "desc"
}
},
"from": 0,
"size": 10
}
a2、指定卡口搜索 聚合统计 每辆车辆 两个时间段的数量, 回溯时间出现为0 ,查询时间大于0 的车辆提出来 ,然后返回该车最新一条过车记录 ,不支持时间排序
//2018-04-27 19:15:01
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"query_string": {
"query": "鄂A*",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2018-02-26 19:15:01",
"lte": "2018-06-27 19:15:01"
}
}
},
{
"query_string": {
"query": "eb822bdf8bf444e7976e64747007357a ba23414a-37f6-4140-96b0-8eb4d7f3 35ad1dbfe2204e31971f1936d12ebb6c",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
}
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"size": 0,
"aggs": {
"motor_vehicle_id": {
"terms": {
"field": "remark1",
"size": 2000,
"include": {
"partition": 0,
"num_partitions": 1
},
"min_doc_count": 1
},
"aggregations": {
"firsttrack": {
"filter": {
"range": {
"pass_time": {
"gte": "2018-02-27 19:15:01",
"lte": "2018-06-27 19:15:01"
}
}
}
},
"secenttrack": {
"filter": {
"range": {
"pass_time": {
"gte": "2018-02-26 19:15:01",
"lte": "2018-02-27 19:15:01"
}
}
}
},
"top_vehicle_hits": {
"top_hits": {
"sort": [
{
"pass_time": {
"order": "desc"
}
}
],
"size": 1
}
},
"having": {
"bucket_selector": {
"buckets_path": {
"firsttrack": "firsttrack>_count",
"secenttrack": "secenttrack>_count"
},
"script": "params.secenttrack==0"
}
}
}
}
}
}
2、落脚点分析 聚合统计 查询车辆在每个卡口上 落脚时长大于 落脚时间(落脚),和小于落脚时间的(经过)
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "鄂AB628E",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2010-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"range": {
"residencetime": {
"gte": 240
}
}
}
]
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"size": 0,
"aggs": {
"tollgate_id": {
"terms": {
"field": "tollgate_id",
"size": 500,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"execution_hint": "map",
"show_term_doc_count_error": false,
"order": [
{
"_count": "desc"
},
{
"_term": "asc"
}
]
},
"aggregations": {
"footholdCount": {
"filter": {
"range": {
"residencetime": {
"gte": 240
}
}
}
},
"travelCount": {
"filter": {
"range": {
"residencetime": {
"lt": 240
}
}
}
}
}
}
}
}
3、 一牌多车 查询 coverplatetype 为0 和1的数据 ,时间不可达,套牌车车牌相同车型不同 -1正常
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"query_string": {
"query": "鄂*",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-12-01 00:00:01"
}
}
}
],
"should": [
{
"term": {
"coverplatetype": 0
}
},
{
"term": {
"coverplatetype": 1
}
}
]
}
}
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"collapse": {
"field": "remark1",
"inner_hits": {
"name": "vehicleCount",
"size": 1,
"_source": {
"includes": [
"plate_no",
"plate_class",
"plate_color"
]
}
}
},
"size": 10
}
4、相似车牌查询
a1、相差1位
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "鄂?4ZNBM 鄂A?ZNBM 鄂A4?NBM 鄂A4Z?BM 鄂A4ZN?M 鄂A4ZNB?",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
}
]
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"collapse": {
"field": "plate_no",
"inner_hits": {
"name": "vehicleCount",
"size": 1
}
},
"size": 10
}
a2、相差2位
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "鄂??ZNBM 鄂?4?NBM 鄂?4Z?BM 鄂?4ZN?M 鄂?4ZNB? 鄂A??NBM 鄂A?Z?BM 鄂A?ZN?M 鄂A?ZNB? 鄂A4??BM 鄂A4?N?M 鄂A4?NB? 鄂A4Z??M 鄂A4Z?B? 鄂A4ZN??",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
}
]
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"collapse": {
"field": "plate_no",
"inner_hits": {
"name": "vehicleCount",
"size": 1
}
},
"size": 10
}
5、频繁过车,根据查询条件统计,该车在查询区域类的过车次数,过滤出次数大于阀值的数据
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"query_string": {
"query": "鄂*",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
}
]
}
}
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"size": 0,
"aggs": {
"motor_vehicle_id": {
"terms": {
"field": "remark1",
"size": 2000,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"collect_mode": "breadth_first",
"execution_hint": "map",
"include": {
"partition": 0,
"num_partitions": 1
},
"show_term_doc_count_error": false
},
"aggregations": {
"cnt": {
"value_count": {
"field": "_index"
}
},
"top_vehicle_hits": {
"top_hits": {
"sort": [
{
"pass_time": {
"order": "desc"
}
}
],
"_source": {
"includes": [
"plate_no",
"plate_class",
"plate_color"
]
},
"size": 1
}
},
"having": {
"bucket_selector": {
"buckets_path": {
"cnt": "cnt"
},
"script": "params.cnt >= 3"
}
}
}
}
}
}
6、历史轨迹查询
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"category": 0
}
},
{
"query_string": {
"query": "鄂AB628E 鄂FL3189",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
}
]
}
}
}
},
"_source": {
"includes": [
"*"
],
"excludes": [
"track.*"
]
},
"sort": {
"pass_time": {
"order": "asc"
}
},
"from": 0,
"size": 20
}
post http://localhost:9200/follow*/_search?request_cache=true
7、同行车查询 vehicle1,vehicle_pair,followTime,vehicle2 根据查询条件取 搜索vehicle1或vehicle2满足查询条件的同行记录,如果v1满足就返回v2,如果v2满足返回v1 。聚合操作返回top1 无法时间排序
{
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"query_string": {
"query": "鄂ANS0F1",
"default_operator": "or",
"fields": [
"plate_no1"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"range": {
"followTime": {
"lte": 11
}
}
}
]
}
},
{
"bool": {
"must": [
{
"query_string": {
"query": "鄂ANS0F1",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category1": "0"
}
},
{
"range": {
"pass_time1": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"range": {
"followTime": {
"lte": 11
}
}
}
]
}
}
]
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"size": 0,
"aggs": {
"vehiclePair": {
"terms": {
"field": "vehiclePair",
"size": 2000,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"collect_mode": "breadth_first",
"execution_hint": "map",
"include": {
"partition": 0,
"num_partitions": 1
},
"show_term_doc_count_error": false
},
"aggregations": {
"top_vehicle_hits": {
"top_hits": {
"sort": [
{
"pass_time": {
"order": "desc"
}
}
],
"size": 1
}
},
"cnt": {
"value_count": {
"field": "_index"
}
},
"having": {
"bucket_selector": {
"buckets_path": {
"cnt": "cnt"
},
"script": "params.cnt >= 1"
}
}
}
}
}
}
8、昼伏夜出 统计查询条件范围内,每辆车白天晚上出现次数,过滤出 晚上/白天大于阀值的数据,返回top1 无法时间排序
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"query_string": {
"query": "鄂*",
"default_operator": "or",
"fields": [
"plate_no"
]
}
},
{
"term": {
"category": "0"
}
},
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
}
]
}
}
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"size": 0,
"aggs": {
"motor_vehicle_id": {
"terms": {
"field": "remark1",
"size": 2000,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"collect_mode": "breadth_first",
"execution_hint": "map",
"include": {
"partition": 0,
"num_partitions": 1
},
"show_term_doc_count_error": false
},
"aggregations": {
"dayOut": {
"filter": {
"term": {
"daynight": 1
}
}
},
"nightOut": {
"filter": {
"term": {
"daynight": 0
}
}
},
"top_vehicle_hits": {
"top_hits": {
"sort": [
{
"pass_time": {
"order": "desc"
}
}
],
"size": 1
}
},
"having": {
"bucket_selector": {
"buckets_path": {
"dayOut": "dayOut>_count",
"nightOut": "nightOut>_count"
},
"script": "double denominator =1; double percent;if(params.dayOut!=0){denominator=params.dayOut;} percent=params.nightOut/denominator;percent>=0"
}
}
}
}
}
}
9、多区域碰撞 查询出满足A,B,C条件的数据,根据车牌和车牌类型聚合统计每辆车在每个条件出现的次数,返回所有区域出现次数都大于0的数据,取top1 没法时间排序。
{
"query": {
"bool": {
"filter": {
"bool": {
"must": {
"term": {
"category": 0
}
},
"should": [
{
"bool": {
"must": [
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"query_string": {
"query": "0278479d174a4ceeb8766e7344abea23",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
},
{
"bool": {
"must": [
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"query_string": {
"query": "0278479d174a4ceeb8766e7344abea24",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
},
{
"bool": {
"must": [
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"query_string": {
"query": "0278479d174a4ceeb8766e7344abea25",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
},
{
"bool": {
"must": [
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"query_string": {
"query": "03d7292867a04359be8eb5b436bf69d8",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
}
],
"minimum_should_match": 1
}
}
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"size": 0,
"aggs": {
"motor_vehicle_id": {
"terms": {
"field": "remark1",
"size": 2000,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"collect_mode": "breadth_first",
"execution_hint": "map",
"include": {
"partition": 0,
"num_partitions": 1
},
"show_term_doc_count_error": false
},
"aggregations": {
"top_vehicle_hits": {
"top_hits": {
"sort": [
{
"pass_time": {
"order": "desc"
}
}
],
"size": 1
}
},
"dsl0": {
"filter": {
"bool": {
"must": [
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"query_string": {
"query": "0278479d174a4ceeb8766e7344abea23",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
}
},
"dsl1": {
"filter": {
"bool": {
"must": [
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"query_string": {
"query": "0278479d174a4ceeb8766e7344abea24",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
}
},
"dsl2": {
"filter": {
"bool": {
"must": [
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"query_string": {
"query": "0278479d174a4ceeb8766e7344abea25",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
}
},
"dsl3": {
"filter": {
"bool": {
"must": [
{
"range": {
"pass_time": {
"gte": "2011-01-01 00:00:01",
"lte": "2019-01-01 00:00:01"
}
}
},
{
"query_string": {
"query": "03d7292867a04359be8eb5b436bf69d8",
"default_operator": "or",
"fields": [
"tollgate_id"
]
}
}
]
}
}
},
"having": {
"bucket_selector": {
"buckets_path": {
"dsl0": "dsl0>_count",
"dsl1": "dsl1>_count",
"dsl2": "dsl2>_count",
"dsl3": "dsl3>_count"
},
"script": "params.dsl0>0&¶ms.dsl1>0&¶ms.dsl2>0&¶ms.dsl3>0"
}
}
}
}
}
}
六、车辆综合查询
1、综合搜索
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"is_car_head": "0"
}
},
{
"term": {
"category": "0"
}
},
{
"query_string": {
"query": "474",
"default_operator": "or",
"fields": [
"vehicle_model"
]
}
},
{
"range": {
"pass_time": {
"gte": "2010-05-01 00:00:00",
"lte": "2019-05-31 23:59:59"
}
}
},
{
"range": {
"timenum": {
"gte": 1500,
"lte": 231500
}
}
}
]
}
}
}
},
"_source": {
"includes": [
"*"
],
"excludes": [
"track.*"
]
},
"sort": {
"pass_time": {
"order": "desc"
}
},
"from": 0,
"size": 10
}
2、分组查询
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"is_car_head": "0"
}
},
{
"term": {
"category": "0"
}
},
{
"query_string": {
"query": "2367",
"default_operator": "or",
"fields": [
"vehicle_model"
]
}
},
{
"range": {
"pass_time": {
"gte": "2010-05-01 00:00:00",
"lte": "2018-05-31 23:59:59"
}
}
},
{
"range": {
"timenum": {
"gte": 1500,
"lte": 231500
}
}
}
]
}
}
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"collapse": {
"field": "plate_no",
"inner_hits": {
"name": "vehicleCount",
"size": 0
}
},
"size": 10
}
3、vehicle_id 查询
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"is_car_head": "0"
}
},
{
"term": {
"category": "0"
}
},
{
"query_string": {
"query": "2367",
"default_operator": "or",
"fields": [
"vehicle_model"
]
}
},
{
"range": {
"pass_time": {
"gte": "2010-05-01 00:00:00",
"lte": "2018-05-31 23:59:59"
}
}
},
{
"range": {
"timenum": {
"gte": 1500,
"lte": 231500
}
}
}
]
}
}
}
},
"_source": {
"excludes": [
"*"
]
},
"from": 0,
"collapse": {
"field": "plate_no",
"inner_hits": {
"name": "vehicleCount",
"size": 0
}
},
"size": 10
}
七、语义查询
1、查询行人结构化数据
post http://localhost:9200/person*/_search?request_cache=true
{
"query": {
"bool": {
"filter": [
{
"term": {
"type_index": "0"
}
},
{
"range": {
"location_mark_time": {
"gte": "1950-01-01 00:00:00",
"lte": "2018-06-20 00:00:00"
}
}
}
]
}
},
"_source": {
"includes": [
"*"
],
"excludes": [
"track.*"
]
},
"sort": {
"location_mark_time": {
"order": "desc"
}
},
"from": 0,
"size": 10
}
2、查询车辆结构化数据
post http://localhost:9200/tracevehicle*/_search?request_cache=true
{
"query": {
"bool": {
"filter": [
{
"term": {
"type_index": "4"
}
},
{
"range": {
"mark_time": {
"gte": "1950-01-01 00:00:00",
"lte": "2018-06-20 00:00:00"
}
}
}
]
}
},
"_source": {
"includes": [
"*"
],
"excludes": [
"track.*"
]
},
"sort": {
"mark_time": {
"order": "desc"
}
},
"from": 0,
"size": 10
}
3、查询骑车人结构化数据
post http://localhost:9200/bicycle*/_search?request_cache=true
{
"query": {
"bool": {
"filter": [
{
"term": {
"type_index": "1"
}
},
{
"range": {
"mark_time": {
"gte": "1950-01-01 00:00:00",
"lte": "2018-06-20 00:00:00"
}
}
}
]
}
},
"_source": {
"includes": [
"*"
],
"excludes": [
"track.*"
]
},
"sort": {
"mark_time": {
"order": "desc"
}
},
"from": 0,
"size": 10
}
4、根据ID查询
a1、行人
post http://localhost:9200/person*/_search?request_cache=true
{
"query": {
"bool": {
"filter": [
{
"term": {
"_id": "43BB63BF2C4C4B269B3831A24C3807FB"
}
}
]
}
},
"from": 0,
"size": 1
}
a2、骑车人
post http://localhost:9200/bicycle*/_search?request_cache=true
{
"query": {
"bool": {
"filter": [
{
"term": {
"_id": "10"
}
}
]
}
},
"from": 0,
"size": 1
}
a3、车辆
post http://localhost:9200/tracevehicle*/_search?request_cache=true
{
"query": {
"bool": {
"filter": [
{
"term": {
"_id": "deb184cbd0bc4f6fadea94a2d794682e"
}
}
]
}
},
"from": 0,
"size": 1
}