【发布时间】:2015-08-21 19:15:46
【问题描述】:
作为一个简化的示例,我将“书”文档存储在弹性搜索中,以便请求 GET /myindex/book/1 返回类似
{
"id": 1,
"title": "Hamlet",
"author": "William Shakespeare",
"pages": [
{"page_id": 1, "contents": "hello, world . . . this story is very well written"},
{"page_id": 5, "contents": "goodbye, world . . . i am done writing this book"}
]
}
我想做的是运行某种查询,以获取包含单个匹配页面的记录。就像GET /myindex/book/_mySpecialQuery?q=hello 会产生结果[{"page_id": 1, "contents": "hello, world . . . this story is very well written", "_parent": 1}] 和GET /myindex/book/_mySpecialQuery?q=world 会产生结果[{"page_id": 1, "contents": "hello, world . . . this story is very well written", "_parent": 1}, {"page_id": 5, "contents": "goodbye, world . . . i am done writing this book", "_parent": 1}] 其中_parent 是书的ID。
我不能轻易地对数据进行非规范化,因为它来自 Mongo(通过 mongo-connector)。
(这看起来应该很简单,但我还没有看到任何好的方法来做到这一点——如果我只是在看错误的术语等,请用链接评论)
【问题讨论】:
标签: elasticsearch