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处理多表关联的方式或者说 ...
随机推荐
- 关于VSTS自动Build报错问题之Microsoft.Net.Compilers
报错内容如下: --06T11::.6035712Z ##[error]Dotnet command failed with non-zero exit code on the following p ...
- SQL读取注册表值
最近写一个自动检查SQL Serve安全配置的检查脚本,需要查询注册表,下面是使用SQL查询注册表值的方法. ) ) ) ) --For Named instance --SET @Instance ...
- Sys.WebForms.PageRequestManagerParserErrorException: 常见的原因是:通过调用Response.Write()修改相应时,将启用响应筛选器、HttpModules或服务器追踪
Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的消息,之所以出现此错误,常见的原因是:通过调用Response.Writ ...
- models的单表操作
orm创建数据库 from django.db import models # Create your models here. class Book(models.Model): name = mo ...
- 7、ORM
CRUD(create.retrieve.update.delete) left join right join inner join one2one one2many many2many 1.For ...
- Visual Studio Code (vscode)编译C++
Visual Studio Code (简称 VS Code / VSC) 是一款免费开源的现代化轻量级代码编辑器,支持几乎所有主流的开发语言的语法高亮.智能代码补全.自定义热键.括号匹配.代码片段. ...
- mongodb的安装和启动
1.在mongodb的官网上下载安装包 https://www.mongodb.com/download-center 选择对应你的系统的安装包下载 如果下载不了 可以使用这个链接下载http://d ...
- [T-ARA][TIAMO]
歌词来源:http://music.163.com/#/song?id=439915067 改了一版格式,先尝试一下,考虑到总不能永远只看着拼音读,所以想把发音按照韩文字来写,以后争取看着韩文字唱. ...
- BZOJ 1051 受欢迎的牛 缩点
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1051 题目大意: 每一头牛的愿望就是变成一头最受欢迎的牛.现在有N头牛,给你M对整数( ...
- cogs [HZOI 2015]有标号的二分图计数
题目分析 n个点的二分染色图计数 很显然的一个式子 \[ \sum_{i=0}^n\binom{n}{i}2^{i(n-i)} \] 很容易把\(2^{i(n-i)}\)拆成卷积形式,前面讲过,不再赘 ...