【发布时间】:2020-09-13 17:35:04
【问题描述】:
据我所知,当我将对象声明为嵌套对象时,它创建了一个类似数组的结构来存储该对象类型的多个对象。 这是映射 json 文件的示例。
{
"employee": {
"dynamic": "strict",
"properties": {
"id": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"previous_job_documents": {
"type": "nested",
"properties": {
"id": {
"type": "keyword"
},
"status": {
"type": "keyword"
},
"type": {
"type": "integer"
}
}
}
}}}
从弹性中获取的示例数据。
"data": {
"nodes": {
"totalCount": 465,
"edges": [
{
"id": "b6ecb8aa-4d12-44d6-8ed7-9ee1003d0d54",
"name": "test",
"previous_job_documents": [
{
"type": "RELIEVING_LETTER",
"status": "NOT_SUBMITTED"
},
{
"type": "OFFER_LETTER",
"status": "SUBMITTED"
},
{
"type": "PAYSLIP_FIRST_MONTH",
"status": "VERIFIED"
},
{
"type": "PAYSLIP_SECOND_MONTH",
"status": "NOT_SUBMITTED"
},
{
"type": "PAYSLIP_THIRD_MONTH",
"status": "NOT_SUBMITTED"
}
]
}
]
}}}
问题:我想编写一个过滤器,它会找到所有名称为 test 且 RELIEVING_LETTER 为 NOT_SUBMITTED 且 OFFER_LETTER 为 SUBMITTED 的员工。
这是我在过滤器中尝试的:
{
"filters": {
"Employee":
{"AND": [{"name": "test"},
{
"path": "previous_job_documents"
"AND": [
{
"term": {
"previous_job_documents.type": {
"value": "RELIEVING_LETTER"
}
}
},
{
"term": {
"previous_job_documents.status": {
"value": "NOT_SUBMITTED"
}
}
},
{
"term": {
"previous_job_documents.type": {
"value": "OFFER_LETTER"
}
}
},
{
"term": {
"previous_job_documents.status": {
"value": "SUBMITTED"
}
}
}
]
}
]
}
}
}
【问题讨论】:
标签: elasticsearch graphql kibana