pyhton+ES6.0数据查询(二)
来源:互联网 发布:东方财富指标源码 编辑:程序博客网 时间:2024/06/14 06:03
1、查询所有的信息
# 查询所有数据数据中的前5条body = { "query": { 'match_all': {} }, # "size": 50,#不填写的话,默认为10}res = es.search(index='awlogs', doc_type='location_as_domain_log', body=body)soucelist= res['hits']['hits']print "the lens of soucelist: ",len(soucelist)for each in soucelist: print each["_source"]the lens of soucelist: 10
2、term与terms的查询
1、term查询
#查询testip='123.56.11.75'的所有数据body = { "query": { 'term': { "testip":"123.56.11.75", }, },}res = es.search(index='awlogs', doc_type='location_as_domain_log', body=body)print res
2、terms查询
#查询testip='123.56.11.75'或者testip='8.8.8.8'的所有数据body = { "query": { 'terms': { "testip":["123.56.11.75","8.8.8.8"] }, },}res = es.search(index='awlogs', doc_type='location_as_domain_log', body=body)
3、match与multi_match查询
样例数据如下:
1、match
查询name字段包含郑州关键字的所有信息。
body = { "query": { 'match': { "name": "郑州" }, },}res = es.search(index='awlogs', doc_type='location_as_domain_log', body=body)
查询结果如下:
{ "took": 9, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 1, "max_score": 0.5753642, "hits": [ { "_index": "test_index", "_type": "test_doc", "_id": "1", "_score": 0.5753642, "_source": { "name": "郑州埃文", "addr": "郑州市航航路", "com_id": "001" } } ] }}
2、multi_match
查询name或者addr字段中包含郑州的所有数据
body = { "query": { 'multi_match': { "query": "郑州", "fields": ["name", "addr"] }, },}
查询结果如下:
{ "took": 9, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 2, "max_score": 0.5753642, "hits": [ { "_index": "test_index", "_type": "test_doc", "_id": "2", "_score": 0.5753642, "_source": { "name": "武汉埃文", "addr": "郑州市航海路", "com_id": "002" } }, { "_index": "test_index", "_type": "test_doc", "_id": "1", "_score": 0.5753642, "_source": { "name": "郑州埃文", "addr": "郑州市航航路", "com_id": "001" } } ] }}
阅读全文
0 0
- pyhton+ES6.0数据查询(二)
- pyhton 数据结构二
- python+ES6.0查询(一)
- 数据查询(二)
- SQL数据查询(二)
- 【Pyhton 笔记】--杂谈【0】
- 实验二 数据的查询
- 二十二.数据的查询
- Hibernate中的数据查询(二)
- SQL 语句(二)--------------数据查询(简单查询)
- 20161228:for pyhton网络数据采集02
- windows安装pyhton数据挖掘扩展库
- 用Pyhton获取中国天气网数据
- ES6语法摘要二
- ES6知识库汇总二
- es6-函数(二)
- 全面认识ES6(二)
- ES6(二)
- Mac OS 终端命令行执行总是出现 command not found
- Hadoop 生态圈介绍
- Spring aop最简形式
- myeclipse的JS出现红叉叉解决方法
- kindle 资源汇总
- pyhton+ES6.0数据查询(二)
- FFmpeg实现视频水印/剪切/压缩/旋转/滤镜/美颜(android )
- 测试使用csdn的markdown
- PostgreSQL的MVCC并发处理方式
- leetcode 257. Binary Tree Paths(DFS)
- opengl fbo离屏渲染,处理Android截屏卡顿太久。
- JACK_C#_内存分配
- Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=
- OpenCV2.4.13 中 选取roi区域,任意形状(矩形,不规则多边形,圆形,椭圆,手动指定形状)