我想从另一个内部数据集创建一个只包含“_id”的数据集。如果我想使这个新数据集尽可能小,因为这只用作前一个数据集中所有项的列表。但是我们也会得到所有的下划线属性。当从Sesam中提取数据时,有什么方法可以解决这个问题吗?
发布于 2018-02-27 19:20:43
这可以通过在数据集和外部客户端之间添加一个层来解决。
{
"_id": "x",
"type": "pipe",
"source": {
"type": "embedded",
"entities": [{
"_id": "foo",
"bar": "baz"
}]
}
}这会产生一个包含许多内部变量(_updated等)的数据集。
如果外部客户端使用此数据集,则它们将按原样获取数据集。
最佳实践是不允许外部客户端直接使用数据集,因为这将使重构内部结构变得更加困难,而是通过http_endpoint公开此数据。
{
"_id": "x-out",
"type": "pipe",
"source": {
"type": "dataset",
"dataset": "x"
},
"sink": {
"type": "http_endpoint"
},
"transform": {
"type": "dtl",
"rules": {
"default": [
["copy", "_id"]
]
}
}
}这将从/api/publishers/x-out/entities端点生成以下输出:
[
{
"_id": "foo"
}
]https://stackoverflow.com/questions/49007319
复制相似问题