elasticsearch - 弹性:嵌套查询或查询弹性文档的文档键,其值为键、值对的数组
问题描述
我正在尝试在弹性中形成查询,文档的存储方式如下-
{
"data": [
{
"value": "Lorem ipsum, Lorem ipsum",
"source": [
"abc.com", "xyz.com"
]
},
{
"value": "Lorem ipsum Lorem ipsum",
"source": [
"wxy.com", "osa.com"
]
}
]
}
我想按某个来源过滤文档。
我从这里得到了一些想法,但它不起作用。它返回该字段的所有查询中的所有记录。
到目前为止,我已经用尽了我所知道的所有查询排列和组合。那么,知道如何实现这一目标吗?
映射:-
{
"mappings": {
"_document_name_": {
"properties": {
"data": {
"properties": {
"source": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"value": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
}
询问:-
{
"query": {
"nested": {
"path": "address",
"query": {
"bool": {
"must_not": [
{ "match": {"data.source": "abc.com"}}
]
}
}
}
}
}
解决方案
推荐阅读
- css - Angular Material MatFormField appearance="fill" 主题问题
- c# - 使用 stardog 从 C# 发送 SPARQL 查询:“无法在读取端点上执行更新查询”
- ios - 某些 iphone 中的 2 列 collectionview 大小问题
- node.js - 在带有时间戳的 kibana 中没有结果符合您的搜索条件
- r - 使用具有多个条件的 ifelse 编程 R
- python - 使用 dateutil.parse 解析不完整的日期
- code-analysis - Visual Studio 2017 代码分析 - 有哪些选项?
- spring-boot - 将 JAX-RPC Web 服务迁移到 Spring-WS
- python - 在 Python 中解码 unicode 字符串变量
- android - Android可以在应用程序处于前台时停止服务吗?