有人知道是否有一种方法可以构建一个弹性搜索查询,该查询按日期对数组进行排序并仅查询最年轻的项目?为了说明我的意思,这是我的数据示例:
[{
_id: "51cd3ae45b99bd960ee0b425",
name: "Example entry",
documents: [
{
title: "Document Title 1",
subDocuments: [
{
date: "Mon Jul 08 2013 12:14:04 GMT+0200 (CEST)",
title: "start working"
},
{
date: "Fri Jul 11 2013 12:14:04 GMT+0200 (CEST)",
title: "finished"
},
{
date: "Thu Jul 10 2013 12:14:04 GMT+0200 (CEST)",
title: "working"
}
]
}
]
}, {
_id: "51cd3ae45b99bd960ee0b426",
name: "Example entry 2",
documents: [
{
title: "Document Title 1",
subDocuments: [
{
date: "Mon Jul 08 2013 12:14:04 GMT+0200 (CEST)",
title: "start working"
},
{
date: "Fri Jul 11 2013 12:14:04 GMT+0200 (CEST)",
title: "working"
}
]
}
]
}]
在此数据中,我想查询“工作”值。如您所见,第一个文档的子文档标题在其最后状态下已完成,因此该文档不允许出现在结果集中。
谁能给我一个提示如何建立查询以满足我的要求?还是目前这不可能,必须在客户端代码中开发?
谢谢和问候克斯滕