按键的Freebase查询

时间:2013-05-23 00:08:59

标签: json freebase mql

我是Freebase的新手并编写了以下查询:

[{
  "key": "Ehingen",
  "postal_codes": [],
  "/location/statistical_region/population": [{
    "number": null,
    "year": null,
    "source": null
  }],
"type": "/location/citytown"
}]

如果有一个城市有Key,结果是正确的,但是如果有多个城市,我会收到错误:

Unique query may have at most one result. Got 6

我该如何正确编写代码?

感谢您在前进方面提供的帮助

1 个答案:

答案 0 :(得分:2)

目前尚不清楚您如何使用key属性或您认为的含义。密钥是强标识符,通常在单个名称空间中查找(例如英语维基百科,MusicBrainz,国会图书馆等)。查询不受命名空间约束的键值是非常不寻常的。

这是一个有效的最小转换:

[{
  "key": [{
    "value": "Ehingen",
    "namespace": null
  }],
  "postal_codes": [],
  "/location/statistical_region/population": [{
    "number": null,
    "year": null,
    "source": null
  }],
  "type": "/location/citytown"
}]

但你也可能意味着:

[{
  "name": "Ehingen",
  "postal_codes": [],
  "/location/statistical_region/population": [{
    "number": null,
    "year": null,
    "source": null
  }],
  "type": "/location/citytown"
}]

[{
  "name~=": "Ehingen",
  "name": null,
  "postal_codes": [],
  "/location/statistical_region/population": [{
    "number": null,
    "year": null,
    "source": null
  }],
  "type": "/location/citytown"
}]

[{
  "name~=": "Ehingen*",
  "name": null,
  "postal_codes": [],
  "/location/statistical_region/population": [{
    "number": null,
    "year": null,
    "source": null
  }],
  "type": "/location/citytown"
}]

其他可能性包括使用Freebase Search API和查询除英语之外的其他语言。