1.数据写入: zjtest7-frontend:/usr/local/logstash-2.3.4/config# curl -XPOST http://192.168.32.80:9200/logstash-2015.06.21/testlog -d '{ "date" :"19999999999", "user":"scan188", "mesg":"first message into Elasticsearch" }' {"_index":"logstash-2015.06.21","_type":"testlog","_id":"AVbklB1aEY-onx06xxpY","_version":1,"_shards":{"total":2,"successful":2,"failed":0},"created":true}zjtest7-frontend:/usr/local/logstash- 2.3.4/config# 2.获取数据: zjtest7-frontend:/usr/local/logstash-2.3.4/config# curl -XGET http://192.168.32.80:9200/logstash-2015.06.21/testlog/AVbklB1aEY-onx06xxpY {"_index":"logstash-2015.06.21","_type":"testlog","_id":"AVbklB1aEY-onx06xxpY","_version":1,"found":true,"_source":{ "date" :"19999999999", "user":"scan188", "mesg":"first message into Elasticsearch" }}zjtest7-frontend:/usr/local/logstash-2.3.4/config# _source 里的内容,正是之前写入的数据。 }}zjtest7-frontend:/usr/local/logstash-2.3.4/config# curl -XGET http://192.168.32.80:9200/logstash-2015.06.21/testlog/AVbklB1aEY-onx06xxpY/_source { "date" :"19999999999", "user":"scan188", "mesg":"first message into Elasticsearch" 来指明要获取的数据部分。 3.数据删除 删除2天前的数据: [root@dr-mysql01 sbin]# cat del_index.sh .~ /.bash_profile v_date=`date +%Y.%m.%d --date='2 days ago'`; echo $v_date curl -XDELETE http://192.168.32.80:9200/logstash-*-$v_date 9.2 搜索请求: }}]}}zjtest7-frontend:/usr/local/logstash-2.3.4/config# curl -XGET http://192.168.32.80:9200/logstash-2015.06.21/testlog/_search?q=first {"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"logstash-2015.06.21","_type":"testlog","_id":"AVbklB1aEY- onx06xxpY","_score":0.30685282,"_source":{ "date" :"19999999999", "user":"scan188", "mesg":"first message into Elasticsearch" 搜索条件为first 1.querystring 语法: 上例中,?q=后面写的就是querystring 语法,鉴于这部分内容会在Kibana上经常使用,这里详细解析一下语法: 1.全文检索:直接写搜索的单词,如上例中的first 2.单字段的全文搜索:在搜索单词之前加上字段名和冒号,比如,如果知道单词first 肯定出现在mesg字段,可以写作mesg:first }}]}}zjtest7-frontend:/usr/local/logstash-2.3.4/config# curl -XGET http://192.168.32.80:9200/logstash-2015.06.21/testlog/_search?q=mesg:first {"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"logstash-2015.06.21","_type":"testlog","_id":"AVbklB1aEY- onx06xxpY","_score":0.30685282,"_source":{ "date" :"19999999999", "user":"scan188", "mesg":"first message into Elasticsearch" }}]}}zjtest7-frontend:/usr/local/logstash-2.3.4/config# 3.单字段的精确检索:在搜索单词前后加双引号,比如user:"chenlin7" zjtest7-frontend:/usr/local/logstash-2.3.4/config# curl -XGET http://192.168.32.80:9200/logstash-2015.06.21/testlog/_search?q=user:"scan188" {"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"logstash-2015.06.21","_type":"testlog","_id":"AVbklB1aEY- onx06xxpY","_score":0.30685282,"_source":{ "date" :"19999999999", "user":"scan188", "mesg":"first message into Elasticsearch" }}]}}zjtest7-frontend:/usr/local/logstash-2.3.4/config#
数据接口示例
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
linux实时查看java接口数据
本文详细介绍了如何在Linux环境中结合Java Spring Boot应用程序和Python脚本来实时(或定期)查看Java接口的数据。
Python Java 应用程序 Linux 实时接口数据 -
python 数据接口示例
python 读取数据接口 ip 字段插入本地文件
python 读取 数据 接口处理 -
List接口简单示例
package cn.itcast.demo;i
System Test Stack