elastic search 查询
eelastic search主要有两种查询方式,一种是查询字符串,一种是请求体(json格式)查询。
查询字符串:
查询字符串的功能相对简单,使用容易。
比如GET http://localhost:9200/list/doc/_search,直接在游览器地址栏输入以上地址,elastic search会返回json格式字符串,意思是查询所有list索引下面类型为doc的文档。
那如果我是 GET http://localhost:9200/_search呢?没错就是在查询所有索引所有类型中的文档,值得一提的是elastic search 将在7以后版本取消类型(type)这一概念。
现在假如我有这样格式的文档(导入bank索引详细见我关于logstash导入elastic search的博客)
{
"_index": "bank",
"_type": "account",
"_id": "25",
"_version": 1,
"_score": 1,
"_source": {
"account_number": 25,
"balance": 40540,
"firstname": "Virginia",
"lastname": "Ayala",
"age": 39,
"gender": "F",
"address": "171 Putnam Avenue",
"employer": "Filodyne",
"email": "virginiaayala@filodyne.com",
"city": "Nicholson",
"state": "PA"
}
}
我想查找 firstname下面名为Virginia的所有账户,那么可以使用如下查询字符串
GET http://localhost:9200/bank/account/_search?q=firstname:Virginia
返回结果
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 4.882802,
"hits": [
{
"_index": "bank",
"_type": "account",
"_id": "25",
"_score": 4.882802,
"_source": {
"account_number": 25,
"balance": 40540,
"firstname": "Virginia",
"lastname": "Ayala",
"age": 39,
"gender": "F",
"address": "171 Putnam Avenue",
"employer": "Filodyne",
"email": "virginiaayala@filodyne.com",
"city": "Nicholson",
"state": "PA"
}
}
]
}
}
GET /bank/account/_search
{
"query": {
"bool": {
"must":[
{ "match": { "firstname": "Virginia" }},
{ "match": { "lastname": "Ayala" }}
]
}
}
}
elastic search 查询的更多相关文章
- elastic search查询命令集合
Technorati 标签: elastic search,query,commands 基本查询:最简单的查询方式 query:{"term":{"title" ...
- elastic search 查询语句
部署了半个月,分析一下数据: 需要提前知道的是,tpot中,每天的数据存一个index,然后每个index里面有不同的type,每条请求一个document 共24万条请求: 查看整个集群所有数据 以 ...
- 分库分表后跨分片查询与Elastic Search
携程酒店订单Elastic Search实战:http://www.lvesu.com/blog/main/cms-610.html 为什么分库分表后不建议跨分片查询:https://www.jian ...
- Elastic Search操作入门
前言 Elastic Search是基于Lucene这个非常成熟的索引方案,另加上一些分布式的实现:集群,sharding,replication等.具体可以参考我同事写的文章. 本文主要介绍ES入门 ...
- tpot从elastic search拉攻击数据之一 找本地数据端口
前面,我们已经在ubuntu服务器上部署好了tpot,并启动进行数据捕获 可以通过64297端口登陆到kibana可视化平台查看捕获到攻击的情况. 现在要拉取攻击数据了,但是该怎么拉呢? 看了一上午的 ...
- java连接elastic search 9300
java连接elastic search 导入jar包:https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/_maven ...
- elastic search使用
elastic使用 使用python时注意保持一个好习惯:不要使用类似str.type这样的变量名,很容易引发错误: https://blog.csdn.net/lifelegendc/article ...
- elastic search远程测试
elastic search远程测试 推荐:elastic官方教程:https://www.elastic.co/guide/en/elasticsearch/reference/6.2/index. ...
- 深入分析Elastic Search的写入过程
摘要 之前写过一篇ElasticSearch初识之吐槽,不知觉竟然过去了两年了.哎,时光催人老啊.最近又用到了ES,想找找过去的总结文档,居然只有一篇,搞了半年的ES,遇到那么多的问题,产出只有这么点 ...
随机推荐
- 【Social listening实操】用大数据文本挖掘,来洞察“共享单车”的行业现状及走势
本文转自知乎 作者:苏格兰折耳喵 ----------------------------------------------------- 对于当下共享单车在互联网界的火热状况,笔者想从大数据文本挖 ...
- py库: jieba (中文词频统计) 、collections (字频统计)、WordCloud (词云)
先来个最简单的: # 查找列表中出现次数最多的值 ls = [1, 2, 3, 4, 5, 6, 1, 2, 1, 2, 1, 1] ls = ["呵呵", "呵呵&qu ...
- python学习笔记_week22
note 知识点概要 - Session - CSRF - Model操作 - Form验证(ModelForm) - 中间件 - 缓存 - 信号 内容详细: 1. Session 基于Cookie做 ...
- web.xml配置重理解
<context-param> <param-name>home-page</param-name> <param-value>home.jsp< ...
- nodejs操作monggodb数据库封装
var MongoClient=require('mongodb').MongoClient; var DbUrl='mongodb://localhost:27017/productmanage'; ...
- <table>导出excal
<table>导出excal 将<table>导出为excal文件,这里介绍两种方法. 1.直接写代码,拼接出excal文件的字符串,然后直接用a标签下载.本人没有是试过,在此 ...
- Swoole 结合TP5创建http服务
下载TP5框架,在项目根目录下创建server目录 http_service.php <?php //创建服务 $http = new swoole_http_server("0.0. ...
- selenium初次接触-1
10月30日 web自动化测试的两种方式:模拟整个http客户端(压力测试,取代浏览器和人,直接和服务端进行交互),模拟用户操作(功能测试,取代人) selenium是自动化浏览器的工具包,可以用于各 ...
- 机器学习-文本数据-文本的相关性矩阵 1.cosing_similarity(用于计算两两特征之间的相关性)
函数说明: 1. cosing_similarity(array) 输入的样本为array格式,为经过词袋模型编码以后的向量化特征,用于计算两两样本之间的相关性 当我们使用词频或者TFidf构造出 ...
- as2 shareObject本地缓存存储位置:
shareObject本地缓存存储位置: win7系统用户到C:\Users\[你的用户名]\AppData\Roaming\Macromedia\Flash Player\#SharedObject ...