elasticsearch_dsl 的nested
在工作中会碰到这样的一个需求,mapping中定义的类型是nested
{
"judgement":{
"mappings":{
"content":{
"_all":{
"enabled":false
},
"_routing":{
"required":true
},
"properties":{
"fullJudgement":{
"properties":{
"caseNumber":{
"type":"text",
"index":false,
"store":true,
"norms":false
},
"caseType":{
"type":"keyword",
"index":false,
"doc_values":false
},
"court":{
"type":"keyword",
"index":false,
"store":true,
"doc_values":false
},
"courtHierarchy":{
"properties":{
"level1":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
},
"level2":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
}
}
},
"courtList":{
"type":"keyword",
"doc_values":false
},
"courtOpinion":{
"type":"text",
"index":false,
"store":true,
"norms":false
},
"fullCourt":{
"type":"keyword",
"index":false,
"store":true
},
"hasHistoricalJudgement":{
"type":"boolean",
"index":false,
"store":true,
"doc_values":false
},
"hasSimilarJudgement":{
"type":"boolean",
"index":false,
"store":true,
"doc_values":false
},
"historicalJudgementTimeLines":{
"type":"nested",
"properties":{
"historicalJudgements":{
"type":"nested",
"properties":{
"caseNumber":{
"type":"keyword",
"index":false,
"doc_values":false
},
"courtName":{
"type":"keyword",
"index":false,
"doc_values":false
},
"isCurrentJudgement":{
"type":"boolean",
"index":false,
"doc_values":false
},
"isRecorded":{
"type":"boolean",
"index":false,
"doc_values":false
},
"judgementDate":{
"type":"date",
"index":false,
"ignore_malformed":true,
"format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"judgementId":{
"type":"keyword",
"index":false,
"doc_values":false
},
"judgementType":{
"type":"keyword",
"index":false,
"doc_values":false
},
"title":{
"type":"text",
"index":false,
"norms":false
},
"trialRound":{
"type":"short",
"index":false,
"doc_values":false,
"coerce":true
}
}
},
"judgementDate":{
"type":"date",
"index":false,
"ignore_malformed":true,
"format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
},
"id":{
"type":"keyword",
"store":true,
"doc_values":false
},
"judgementAbstract":{
"type":"text",
"index":false,
"norms":false
},
"judgementContent":{
"type":"text",
"norms":false,
"analyzer":"ik_max_word"
},
"judgementDate":{
"type":"date",
"store":true,
"ignore_malformed":true,
"format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"judgementType":{
"type":"keyword",
"store":true,
"eager_global_ordinals":true
},
"judgementTypeText":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"judges":{
"type":"keyword",
"doc_values":false
},
"keywords":{
"type":"keyword",
"store":true,
"eager_global_ordinals":true
},
"opponentLawyers":{
"type":"nested",
"properties":{
"avatarUrl":{
"type":"keyword",
"index":false,
"doc_values":false
},
"claimProfileId":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"claimUserId":{
"type":"keyword",
"index":false,
"doc_values":false
},
"isClaimed":{
"type":"boolean",
"index":false,
"doc_values":false
},
"lawFirm":{
"type":"keyword",
"doc_values":false
},
"name":{
"type":"keyword",
"doc_values":false
},
"originalLawFirm":{
"type":"keyword",
"index":false,
"doc_values":false
},
"originalLawyerName":{
"type":"keyword",
"index":false,
"doc_values":false
},
"profileId":{
"type":"keyword",
"index":false,
"doc_values":false
},
"status":{
"type":"short",
"index":false,
"doc_values":false
}
}
},
"opponents":{
"type":"keyword",
"doc_values":false
},
"otherLawyers":{
"type":"nested",
"properties":{
"avatarUrl":{
"type":"keyword",
"index":false,
"doc_values":false
},
"claimProfileId":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"claimUserId":{
"type":"keyword",
"index":false,
"doc_values":false
},
"isClaimed":{
"type":"boolean",
"index":false,
"doc_values":false
},
"lawFirm":{
"type":"keyword",
"doc_values":false
},
"name":{
"type":"keyword",
"doc_values":false
},
"originalLawFirm":{
"type":"keyword",
"index":false,
"doc_values":false
},
"originalLawyerName":{
"type":"keyword",
"index":false,
"doc_values":false
},
"profileId":{
"type":"keyword",
"index":false,
"doc_values":false
},
"status":{
"type":"short",
"index":false,
"doc_values":false
}
}
},
"paragraphs":{
"type":"nested",
"properties":{
"subParagraphs":{
"type":"nested",
"properties":{
"number":{
"type":"short",
"index":false,
"doc_values":false,
"coerce":true
},
"text":{
"type":"text",
"index":false,
"norms":false
}
}
},
"type":{
"type":"short",
"index":false,
"doc_values":false,
"coerce":true
},
"typeText":{
"type":"keyword",
"doc_values":false
}
}
},
"proponentLawyers":{
"type":"nested",
"properties":{
"avatarUrl":{
"type":"keyword",
"index":false,
"doc_values":false
},
"claimProfileId":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"claimUserId":{
"type":"keyword",
"index":false,
"doc_values":false
},
"isClaimed":{
"type":"boolean",
"index":false,
"doc_values":false
},
"lawFirm":{
"type":"keyword",
"doc_values":false
},
"name":{
"type":"keyword",
"doc_values":false
},
"originalLawFirm":{
"type":"keyword",
"index":false,
"doc_values":false
},
"originalLawyerName":{
"type":"keyword",
"index":false,
"doc_values":false
},
"profileId":{
"type":"keyword",
"index":false,
"doc_values":false
},
"status":{
"type":"short",
"index":false,
"doc_values":false
}
}
},
"proponents":{
"type":"keyword",
"doc_values":false
},
"publishBatch":{
"type":"text",
"index":false,
"norms":false
},
"publishDate":{
"type":"date",
"index":false,
"doc_values":false,
"ignore_malformed":true,
"format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"publishType":{
"type":"keyword",
"index":false
},
"publishTypeHierarchy":{
"properties":{
"level1":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
},
"level2":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
}
}
},
"publishTypeList":{
"type":"keyword",
"doc_values":false
},
"publishTypeText":{
"type":"keyword",
"index":false,
"store":true,
"doc_values":false
},
"reason":{
"type":"keyword",
"index":false,
"doc_values":false
},
"reasonHierarchy":{
"properties":{
"level1":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
},
"level2":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
},
"level3":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
},
"level4":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
},
"level5":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
}
}
},
"reasonList":{
"type":"keyword",
"doc_values":false
},
"regionHierarchy":{
"properties":{
"level1":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
},
"level2":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
},
"level3":{
"type":"keyword",
"index":false,
"eager_global_ordinals":true
}
}
},
"regionList":{
"type":"keyword",
"doc_values":false
},
"regulationGroupByTrialRoundInfos":{
"type":"nested",
"properties":{
"regulations":{
"type":"nested",
"properties":{
"id":{
"type":"keyword",
"doc_values":false
},
"sectionParagraphs":{
"type":"nested",
"properties":{
"isHit":{
"type":"boolean",
"index":false,
"doc_values":false
},
"text":{
"type":"text",
"index":false,
"norms":false
},
"type":{
"type":"short",
"index":false,
"doc_values":false,
"coerce":true
}
}
},
"text":{
"type":"keyword",
"doc_values":false
}
}
},
"trialRound":{
"type":"long"
},
"trialRoundText":{
"type":"keyword",
"index":false,
"doc_values":false
}
}
},
"similarJudgement":{
"properties":{
"attitude":{
"type":"short",
"index":false,
"doc_values":false,
"coerce":true
},
"court":{
"type":"keyword",
"index":false,
"doc_values":false
},
"id":{
"type":"keyword",
"index":false,
"doc_values":false
},
"score":{
"type":"keyword",
"index":false,
"doc_values":false
},
"similarLevel":{
"type":"short",
"index":false,
"doc_values":false,
"coerce":true
},
"title":{
"type":"text",
"index":false,
"norms":false
}
}
},
"sourceName":{
"type":"keyword",
"index":false,
"doc_values":false
},
"sourceType":{
"type":"short",
"index":false,
"doc_values":false,
"coerce":true
},
"sourceUrl":{
"type":"keyword",
"index":false,
"doc_values":false
},
"title":{
"type":"text",
"store":true,
"analyzer":"ik_max_word"
},
"trialRound":{
"type":"short",
"index":false,
"doc_values":false,
"coerce":true
},
"trialRoundText":{
"type":"keyword",
"eager_global_ordinals":true
},
"trialYear":{
"type":"keyword",
"eager_global_ordinals":true
}
}
},
"originalUUID":{
"type":"keyword",
"doc_values":false
},
"originalUuid":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
}
}
}
}
如果想要对fullJudgement.opponentLawyers.name查询二次就需要下面的查询语句
q = Q('nested', path='fullJudgement.opponentLawyers',
query=Q('term', **{'fullJudgement.opponentLawyers.name': '王美丽'}) & Q('term', **{'fullJudgement.opponentLawyers.name': '王美'}))
ms = Search(using=client, index='judgement', doc_type='content').query(q)
elasticsearch_dsl 的nested的更多相关文章
- Nested Loops join时显示no join predicate原因分析以及解决办法
本文出处:http://www.cnblogs.com/wy123/p/6238844.html 最近遇到一个存储过程在某些特殊的情况下,效率极其低效, 至于底下到什么程度我现在都没有一个确切的数据, ...
- Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.
启动tomcat, 出现, ( 之前都是好好的... ) [lk ] ERROR [08-12 15:10:02] [main] org.springframework.web.context.Con ...
- SQL Tuning 基础概述06 - 表的关联方式:Nested Loops Join,Merge Sort Join & Hash Join
nested loops join(嵌套循环) 驱动表返回几条结果集,被驱动表访问多少次,有驱动顺序,无须排序,无任何限制. 驱动表限制条件有索引,被驱动表连接条件有索引. hints:use_n ...
- [LeetCode] Nested List Weight Sum II 嵌套链表权重和之二
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...
- [LeetCode] Flatten Nested List Iterator 压平嵌套链表迭代器
Given a nested list of integers, implement an iterator to flatten it. Each element is either an inte ...
- [LeetCode] Nested List Weight Sum 嵌套链表权重和
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...
- 禁用nested loop join里的spool
禁用nested loop join里的spool 转载自: https://blogs.msdn.microsoft.com/psssql/2015/12/15/spool-operator-and ...
- Android Fragment使用(二) 嵌套Fragments (Nested Fragments) 的使用及常见错误
嵌套Fragment的使用及常见错误 嵌套Fragments (Nested Fragments), 是在Fragment内部又添加Fragment. 使用时, 主要要依靠宿主Fragment的 ge ...
- 1122MySQL性能优化之 Nested Loop Join和Block Nested-Loop Join(BNL)
转自http://blog.itpub.net/22664653/viewspace-1692317/ 一 介绍 相信许多开发/DBA在使用MySQL的过程中,对于MySQL处理多表关联的方式或者说 ...
随机推荐
- fiddler抓包出现Tunnel to
在抓包的时候,有时候会遇到很多的tunnel to,图标是一把锁的形状,如下图: connect是为了建立http tunnel,connect是http众多方法中的其中一种,它跟post.get.p ...
- 一、python小功能记录——监听键盘事件
1.监听键盘按键 from pynput.keyboard import Listener def press(key): print(key.char) with Listener(on_press ...
- Python学习---Django下的Sql性能的测试
安装django-debug-tools Python学习---django-debug-tools安装 性能测试: settings.py INSTALLED_APPS = [ ... 'app01 ...
- 6 Dockerfile指令详解 && ENTRYPOINT 指令
ENTRYPOINT 的格式和 RUN 指令格式一样,分为 exec 格式和 shell 格式. ENTRYPOINT 的目的和 CMD 一样,都是在指定容器启动程序及参数. ENTRYPOINT 在 ...
- C语言基础笔试题一
1.下面的代码输出什么?为什么? void foo(void) { unsigned int a = 6; int b = -20; (a+b > 6)?puts(">6&quo ...
- Mybatis和Mysql的Json类型
Mysql5.7新增加了Json类型字段,但是目前Mybatis中并不支持 1.新建MybatisJsonTypeHandler.java import com.fasterxml.jackson.a ...
- expand_dims函数
>>> x = np.array([1,2]) >>> x.shape (2,) >>> y = np.expand_dims(x, axis=0 ...
- jQuery on()方法绑定动态元素的点击事件实例代码浅析
之前就一直受这个问题的困扰,在jQuery1.7版本之后添加了on方法,之前就了解过,其优越性高于live(),bind(),delegate()等方法,在此之前项目中想用这个来测试结果发现,居然动态 ...
- JDK(一)JDK集合框架
JDK中的集合框架分为两大类:Collection和Map.Collection以一组Object的形式保存元素,Map以Key-Value对的形式保存元素. 上图列出的类并不完整,只列举了平时比较常 ...
- IntelliJ IDEA SVN无法正常使用问题
SVN checkout时候会出现错误:Cannot run program "svn" (in directory "E:\Projects"): Creat ...