在工作中会碰到这样的一个需求,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. Mybatis源码解析优秀博文

    最近阅读了许久的mybatis源码,小有所悟.同时也发现网上有许多优秀的mybatis源码讲解博文.本人打算把自己阅读过的.觉得不错的一些博文列出来.以此进一步加深对mybatis框架的理解.其实还有 ...

  2. 卸载Sharepoint2016后。重新安装提示 系统从以前的安装重新启动,或更新正在等待错误

    卸载Sharepoint2016 重启N遍,不停地重启.需要删除注册表项 下的 .将PendingFileRenameOperations键项删除,再重新安装就可以安装成功.

  3. [翻译] SlideInView

    SlideInView This is a quick and lightweight example of how to present a notification like view from ...

  4. 沉淀再出发:关于IntelliJ IDEA使用的一些总结

    沉淀再出发:关于IntelliJ IDEA使用的一些总结 一.前言 在使用IDEA的时候我们会发现,如果我们先写了一个类的名字,而没有导入这个类的出处,就会提示出错,但是不能自动加入,非常的苦恼,并且 ...

  5. Excel 导出指定行为txt文件(VBA,宏)

    要从Excel 多个sheet内导出指定行为txt文件,懒得用C#了,写个VBA宏 Sub Export() Dim FileName As Variant Dim Sep As String Dim ...

  6. SQL脚本修改表结构

    SQL脚本修改表结构 新建表:create table [表名]([自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,[字段1] nVarChar(50) default ...

  7. 【RabbitMQ】4、三种Exchange模式——订阅、路由、通配符模式

    前两篇博客介绍了两种队列模式,这篇博客介绍订阅.路由和通配符模式,之所以放在一起介绍,是因为这三种模式都是用了Exchange交换机,消息没有直接发送到队列,而是发送到了交换机,经过队列绑定交换机到达 ...

  8. struct class 内存结构初探-内存模型顺序和变量的实际添加顺序一致

    typedef struct structTest { char xchar; int xint; int yint; }xStruct; @interface ViewController () { ...

  9. BZOJ3224:普通平衡树(Splay)

    Description 您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作: 1. 插入x数 2. 删除x数(若有多个相同的数,因只删除一个) 3. 查询x数的排名(若有多个相 ...

  10. ubuntu16.04 Detectron目标检测库配置(包含GPU驱动,Cuda,Caffee2等配置梳理)

    Detectron概述 Detectron是Facebook FAIR开源了的一个目标检测(Object Detection)平台. 用一幅图简单说明下Object Detection.如Mask R ...