0

I am looking to extract list of tourist attractions and their city,state and country information from Freebase. The property that has location is "/location/location/containedby". There are different types for this object, "location/location" or "/base/biblioness/bibs_location". If the object has "/base/biblioness/bibs_location" i can get the value of "city", "state" etc. however if the object only has the type "/location/location" i need to go and get its "containedby" field and redo the above logic.

My question is can i perform a conditional query in Freebase like if type == "/location/location/" get xyz. if type== "/base/biblioness/bibs_location" get abc

MQL:

[{
  "type":   "/travel/tourist_attraction",
  "id":     null,
  "name":   null,
  "name~=": "^San Diego",
  "/location/location/containedby": {
    "type": "/base/biblioness/bibs_location",
    "name": null,
    "id":   null
  },
  "/location/location/geolocation": [{
    "id":        null,
    "latitude":  null,
    "longitude": null
  }]
}]
Tom Morris
  • 10,490
  • 32
  • 53

1 Answers1

0

MQL doesn't support conditional logic, but you can query all the information that you're potentially interested in, making the subqueries optional so they don't filter the results, and then look at what you get back. It'll require conditional code in your result processor, but you won't have to make multiple queries. For example, you could query multiple levels of /location/location/contained by as well as /base/biblioness/bibs_location/state and whatever else you want.

Before you go spending too much time on this though, you might want to check how well populated /base/biblioness/bibs_location is. It looks to me like it's got less than 2K entities.

Tom Morris
  • 10,490
  • 32
  • 53