在工作中会碰到这样的一个需求,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. Docker-容器数据卷

    docker容器数据卷相当于外置的移动硬盘 docker容器数据卷主要功能是:容器的持久化.容器间继承+共享数据 特点: (1)数据卷可以容器之间共享或重用数据 (2)卷中更改可以直接生效 (3)数据 ...

  2. 转贴:如何学好C++语言.docx

    不知道哪里转的.呵呵 抱歉 C++是最难的语言.这个世界上最难的编程语言可能非C++莫属了.你千万不要以为几天就可以学好C++,C++的学习曲线是相当BT的,你可以看看这篇文章.C++是一门很自由的语 ...

  3. 在Eclipse中通过build.xml导入工程

    http://www.zihou.me/html/2012/10/18/7868.html

  4. windows完全卸载office

    运行文件O15CTRRemove.diagcab执行完全卸载. 文件下载地址:https://pan.baidu.com/s/1eSilUJS

  5. unittest:2 执行多条用例,仅执行一次setUp和tearDown

    对象方法setUp()和tearDown() 每个用例执行前后都会被调用.但是有另外一种场景:setUp之后执行完所有用例,最后调用一次tearDown.比如打开网页,多条用例分别验证网页上的元素正确 ...

  6. Yahoo!团队经验:网站性能优化的34条黄金法则

    英文原文:http://developer.yahoo.com/performance/rules.html 1.尽量减少HTTP请求次数 (1)合并文件就是通过把所有的脚本放到一个文件中来减少HTT ...

  7. mysql-5.5 for linux源代码安装

    mysql-5.5 for linux源代码安装 1.使用Yum安装依赖软件包 # yum install -y gcc gcc-c++ gcc-g77 autoconf automake bison ...

  8. 【[HNOI2012]矿场搭建】

    抄题解真开心 我真是越来越菜了 这是点双的板子题,于是求出所有点双,之后讨论 如果点双里之有一个割点,那么如果这个割点炸了,这个点双就出不去了,于是我们得在这个点双内部除了这个割点位置放一个 如果有两 ...

  9. [运维笔记] Nginx编译安装

    yum -y install pcre-devel.x86_64 yum -y install openssl openssl-devel.x86_64 useradd www -s /sbin/no ...

  10. python迭代、列表生成式

    迭代: 迭代对象(Iterable),可以直接作用于for循环的对象,如list / tuple / dict / set / str /等集合数据类型可以直接作用于for循环 >>> ...