elasticsearch的join查询
1.概述
官方文档
https://www.elastic.co/guide/en/elasticsearch/reference/current/joining-queries.html
两种类型的查询
嵌套查询
has_child和has_parent
其中,has_child返回包含特定查询字段文档的父文档;
has_parent返回包含特定查询字段的父文档的子文档。
2.实例
2.1 嵌套查询
GET /_search
{
"query": {
"nested" : {
"path" : "obj1",
"score_mode" : "avg",
"query" : {
"bool" : {
"must" : [
{ "match" : {"obj1.name" : "blue"} },
{ "range" : {"obj1.count" : {"gt" : 5}} }
]
}
}
}
}
}
2.2 has_child 查询
GET /_search
{
"query": {
"has_child" : {
"type" : "blog_tag",
"query" : {
"term" : {
"tag" : "something"
}
}
}
}
}
2.3 has_parent
GET /_search
{
"query": {
"has_parent" : {
"parent_type" : "blog",
"query" : {
"term" : {
"tag" : "something"
}
}
}
}
}
2.4 parent_id 查询
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"my_join_field": {
"type": "join",
"relations": {
"my_parent": "my_child"
}
}
}
}
}
} PUT my_index/_doc/1?refresh
{
"text": "This is a parent document",
"my_join_field": "my_parent"
} PUT my_index/_doc/2?routing=1&refresh
{
"text": "This is a child document",
"my_join_field": {
"name": "my_child",
"parent": "1"
}
}
GET /my_index/_search
{
"query": {
"parent_id": {
"type": "my_child",
"id": "1"
}
}
}
elasticsearch的join查询的更多相关文章
- elasticsearch GIS空间查询问题解决
在GIS行业的应用越来越广泛,GIS最常用根据区域进行空间数据查询 我定义了两个方法,一起来看一下: /** * geodistance filter * 一个过滤器来过滤基于一个特定的距离从 ...
- Mysql 拼接字段查询语句和join查询拼接和时间查询
个人平时记录的,有点乱 1.修改时间字段,如果时间字段的类型是date或者是datetime类型的 update 表名 set 时间字段 = DATE_FORMAT(NOW(),'%Y-%m-%d % ...
- mysql join 查询图
mysql join 查询,特别是对查两个表之间的差集,可以用table字段=null来做. 注意千万不是join on XX!=XX ,这样出来的结果是错误的.
- Map/Reduce中Join查询实现
张表,分别较data.txt和info.txt,字段之间以/t划分. data.txt内容如下: 201001 1003 abc 201002 1005 def 201003 ...
- SQL2-子查询、join查询
SQL常用高级查询包括:Join查询.子查询. 子查询: USE flowershopdb --子查询:在一个select语句使用另一个select 语句作为条件或数据来源. --查询块:一个sele ...
- Elasticsearch文档查询
简单数据集 到目前为止,已经了解了基本知识,现在我们尝试用更逼真的数据集,这儿已经准备好了一份虚构的JSON,关于客户银行账户信息的.每个文档的结构如下: { , , "firstname& ...
- Elasticsearch(GEO)空间检索查询
Elasticsearch(GEO)空间检索查询python版本 1.Elasticsearch ES的强大就不用多说了,当你安装上插件,搭建好集群,你就拥有了一个搜索系统. 当然,ES的集群优化和查 ...
- 利用kibana插件对Elasticsearch进行bool查询
#bool查询#老版本的filtered查询已经被bool代替#用 bool包括 must should must_not filter来完成 ,格式如下:#bool:{# "filter ...
- java操作elasticsearch实现前缀查询、wildcard、fuzzy模糊查询、ids查询
1.前缀查询(prefix) //prefix前缀查询 @Test public void test15() throws UnknownHostException { //1.指定es集群 clus ...
随机推荐
- CxGrid导出Excel时清除颜色的设置
CxGrid导出Excel时清除颜色的设置 (2011-04-25 16:33:23) 转载▼ 标签: it 分类: Delphi http://www.radxe.com/?p=170 cxgrid ...
- [leetcode] 16. Add Binary
这个题目相对有点奇怪,题目如下: Given two binary strings, return their sum (also a binary string). For example, a = ...
- Python学习-26.Python中的三角函数
Python中的三角函数位于math模块内. 引入模块: import math 输出pi import math print(math.pi) 得:3.141592653589793 math模块内 ...
- C# 代码风格要求
一个.cs源文件至多定义两个类型 所有命名空间.类型名称使用Pascal风格(单词首字母大写),私有方法.受保护方法,仍使用Pascal风格命名 本地变量.方法参数名称使用Camel风格(首字母小写, ...
- 阿里云ECS服务器windows环境下配置redis
一.下载解压redis github下载地址:https://github.com/MSOpenTech/redis/tags 下载的是Redis-x64-3.2.100版本,Redis-x64-3. ...
- Mongoose也是个大坑
http://blog.csdn.net/qq_31280709/article/details/53900290 折腾了两个小时,MLGB居然是因为mongoose查询集合的时候自动加s后缀!!!
- win10中shift+右键,在此处打开cmd窗口
通过添加注册表项,实现右击“在此处打开命令行功能” 注册表位置:HKEY_CLASSES_ROOT\Directory\Background\shell\ win10系统用标识右键菜单打开命令行的键, ...
- jQuery基础笔记(2)
day54 筛选器 参考:https://www.cnblogs.com/liwenzhou/p/8178806.html#autoid-1-7-5 筛选器方法 下一个元素: $("#id& ...
- 变不可能为可能 - .NET Windows Form 改变窗体类名(Class Name)有多难?续篇
发布<.NET Windows Form 改变窗体类名(Class Name)有多难?>转眼大半年过去了,要不是在前几天有园友对这篇文章进行评论,基本上已经很少关注它了,毕竟那只是一个解惑 ...
- 理解js事件冒泡事件委托事件捕获
js事件冒泡 javascript的事件传播过程中,当事件在一个元素上出发之后,事件会逐级传播给先辈元素,直到document为止,有的浏览器可能到window为止,这就是事件冒泡现象. <di ...