如何在Palantir Foundry Slate中查询Phonograph2表仅返回指定列?
Foundry Table Search Service 查询指定列解决方案
在Foundry Table Search Service的Search端点中,不支持ElasticSearch风格的columns参数来指定返回列,正确的做法是使用fields参数直接声明需要获取的字段,或者通过projection结构配置包含字段。
方案一:使用fields参数
将请求中的columns替换为fields,修改后的查询语句如下:
{ "tableRids": [ "table_phonograph_rid_12344567" ], "fields": [ "object_id", "year", "name" ], "filter": { "type": "terms", "terms": { "field": "object_id", "terms": ["abcd_1234", "efgh_8765"] } }, "sort": { "year": { "order": "asc" } } }
方案二:使用projection结构
如果需要更灵活的字段配置(比如后续需要排除字段),可以使用projection.includeFields指定要包含的字段:
{ "tableRids": [ "table_phonograph_rid_12344567" ], "projection": { "includeFields": ["object_id", "year", "name"] }, "filter": { "type": "terms", "terms": { "field": "object_id", "terms": ["abcd_1234", "efgh_8765"] } }, "sort": { "year": { "order": "asc" } } }
以上两种方式均可返回你指定的object_id、year、name三列,同时保留原有的筛选和排序逻辑。
内容的提问来源于stack exchange,提问作者Vinh
相关产品推荐
相关产品推荐

