在工作中会碰到这样的一个需求,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的更多相关文章

  1. Nested Loops join时显示no join predicate原因分析以及解决办法

    本文出处:http://www.cnblogs.com/wy123/p/6238844.html 最近遇到一个存储过程在某些特殊的情况下,效率极其低效, 至于底下到什么程度我现在都没有一个确切的数据, ...

  2. 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 ...

  3. SQL Tuning 基础概述06 - 表的关联方式:Nested Loops Join,Merge Sort Join & Hash Join

    nested loops join(嵌套循环)   驱动表返回几条结果集,被驱动表访问多少次,有驱动顺序,无须排序,无任何限制. 驱动表限制条件有索引,被驱动表连接条件有索引. hints:use_n ...

  4. [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. ...

  5. [LeetCode] Flatten Nested List Iterator 压平嵌套链表迭代器

    Given a nested list of integers, implement an iterator to flatten it. Each element is either an inte ...

  6. [LeetCode] Nested List Weight Sum 嵌套链表权重和

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  7. 禁用nested loop join里的spool

    禁用nested loop join里的spool 转载自: https://blogs.msdn.microsoft.com/psssql/2015/12/15/spool-operator-and ...

  8. Android Fragment使用(二) 嵌套Fragments (Nested Fragments) 的使用及常见错误

    嵌套Fragment的使用及常见错误 嵌套Fragments (Nested Fragments), 是在Fragment内部又添加Fragment. 使用时, 主要要依靠宿主Fragment的 ge ...

  9. 1122MySQL性能优化之 Nested Loop Join和Block Nested-Loop Join(BNL)

    转自http://blog.itpub.net/22664653/viewspace-1692317/ 一 介绍  相信许多开发/DBA在使用MySQL的过程中,对于MySQL处理多表关联的方式或者说 ...

随机推荐

  1. Java学习-0

    Java简单介绍 第一个程序Hello World 基本数据类型 对象和类 数据声明 函数声明 参数传递 Java简单介绍 Java的优点:简单.可移植性 JDK (Java Development ...

  2. 用POP动画模拟真实秒钟摆动效果

    用POP动画模拟真实秒钟摆动效果 静态图: 动画图: 此处用到了POP中的Spring系列动画,现提供源码如下: SecondClockView.h 与 SecondClockView.m // // ...

  3. January 03 2017 Week 1st Tuesday

    It is always morning somewhere in the world. 世界上总是有一个地方可以看到阳光. There may be always someone who can e ...

  4. Git 解决方案 commit your changes or stash them before you can merge

    error: Your local changes to the following files would be overwritten by merge: *********** Please, ...

  5. java重载

    public class overLaod { public static void main(String[] args) { // TODO Auto-generated method stub ...

  6. Alpha Scrum5

    Alpha Scrum5 牛肉面不要牛肉不要面 Alpha项目冲刺(团队作业5) 各个成员在 Alpha 阶段认领的任务 林志松:督促和监督团队进度,前端页面编写 林书浩.陈远军:界面设计.美化 吴沂 ...

  7. BZOJ2599:[IOI2011]Race(点分治)

    Description 给一棵树,每条边有权.求一条简单路径,权值和等于K,且边的数量最小.N <= 200000, K <= 1000000 Input 第一行 两个整数 n, k 第二 ...

  8. @PostConstruct与@PreDestroy讲解及实例

    关于在spring  容器初始化 bean 和销毁前所做的操作定义方式有三种: 第一种:通过@PostConstruct 和 @PreDestroy 方法 实现初始化后和销毁bean之前进行的操作 第 ...

  9. Spring(三)之Ioc、Bean、Scope讲解

    Spring容器是Spring Framework的核心.容器将创建对象,将它们连接在一起,配置它们,并管理从创建到销毁的整个生命周期.Spring容器使用DI来管理组成应用程序的组件.这些对象称为S ...

  10. Django实战(二)之模板语言

    该实战教程基于菜鸟教程,菜鸟教程可参考:http://www.runoob.com/django/django-template.html 模板语法,每个框架都有其支持的模板语法,Django的模板语 ...