我使用以下字段和数据创建了CKAN数据存储
"primary_key" : ["Book ID"],
"fields" :[
{"id":"Book ID","type":"number"},
{"id":"Book Name","type":"text"},
{"id":"Author","type":"text"},
{"id":"Publications","type":"text"},
{"id":"Price","type":"text"},
{"id":"Discount","type":"text"}
],
"records": [
{ "Book ID" :"1",
"Book Name" :"Book1",
"Author" :"Author1",
"Publications" :"Pub1",
"Price" :"895",
"Discount" :"5"
},
{ "Book ID" :"2",
"Book Name" :"Book2",
"Author" :"Author2",
"Publications" :"Pub2",
"Price" :"699",
"Discount" :"5"
},
{ "Book ID" :"3",
"Book Name" :"Book3",
"Author" :"Author3",
"Publications" :"Pub3",
"Price" :"500",
"Discount" :"10"
}]
我需要获取一些特定字段。 我使用datastore_search,并给出了需要获取的字段。但是显示错误。
我的搜索代码:
{ "resource_id": "740d27f5-790c-43d8-9d5d-23c8aab9303e",
"fields": [
{ "id": "Book Name"},
{ "id": "Author"}
],
"filters": {"Book Name": "Book1"}
}
答案 0 :(得分:1)
“字段”是列表或逗号分隔的字符串,在这里您将字段指定为对象数组。
尝试以下代码:
{
"resource_id": "740d27f5-790c-43d8-9d5d-23c8aab9303e",
"fields": "Book Name,Author",
"filters": {"Book Name": "Book1"}
}