InvDev
InvDev

Reputation: 13

Freebase Query by Key

I'm a newbie in Freebase and wrote the following Query:

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

If there is one city with the Key, the result is correct, but when there is more than one, I get the error:

Unique query may have at most one result. Got 6

How must I write the code correctly?

Thanks for your help in forward

Upvotes: 1

Views: 139

Answers (1)

Tom Morris
Tom Morris

Reputation: 10540

It's not clear how you're using the key property or what you think it means. Keys are strong identifiers which are normally looked up in a single namespace (e.g. English Wikipedia, MusicBrainz, Library of Congress, etc). It's very unusual to query a key value unconstrained by a namespace.

Here's a minimal transformation which works:

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

but you also might mean:

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

or

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

or

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

Other possibilities include using the Freebase Search API and querying other languages than English.

Upvotes: 2

Related Questions