I'm trying to query freebase to find out all the people who were born in specific day of a year. That is all the people that were born on August 4th regardless to the year.
I tried two methods - trying to reflect certain date (example below) or querying for people with date_of_birth. I'm using regular expression something like:
"date_of_birth~=":"*08-04"
[{
"/type/reflect/any_value": [{
"link": {
"master_property": {
"name": "Date of birth"
}
},
"type": "/type/datetime",
"value~=": "*08-04"
}],
"name": null,
"type": "/common/topic"
}]
I get the following error message:
"*08-04 is a JSON string, but the expected type is /type/datetime"
Is there anyway I can query regular expressions regarding dates?
You can do this easily using the Freebase Search API now like this:
filter=(all type:/common/topic /people/person/date_of_birth:-08-04)
Try it
As a bonus, the results are ranked by notability in Freebase so you get the most notable people born on that day.
Related
I'm attempting to link my Zapier account to my Firebase account to trigger once a new entry is seen within a collection.
I've been having issues with this, and I think this is because of the query I'm using:
"orderBy": [{
"field": {
"fieldPath": "startDateInMilliseconds"
},
"direction": "DESCENDING"
}]
(this is the default example given in documentation, with my field filled in). I believe the issue stems from the fieldPath, as the field for the collection I'm ordering by is under a subcategory "d".
Here's a picture of the data that works with the above query.
He's a picture of the data I'm working with, this one does not work.
Image with the start date field.
Without this subcategory, the query works fine in testing, but within this category, the query returns an error, saying it's unable to find any documents.
Does anyone know how to change the query to work for my situation? Thanks.
If you're trying to query a property of the d field map, you will need to use dot notation to find it.
"orderBy": [{
"field": {
"fieldPath": "d.dateInMilliseconds"
},
"direction": "DESCENDING"
}]
My current query is this:
[{
"type": "/people/person",
"also:type": "/film/actor",
"name": "Chuck Norris",
"/imdb/topic/name_id": null,
"date_of_birth": null,
"/film/actor/film": [{
"film": [{
"name": null,
"imdb_id": []
}]
}]
}]
And this works fine for actors. But I want to return films, given a name or IMDB Name ID etc., for anyone who has worked in films. So directors, products, writers etc.
To do this though, requires lots of different types, like: executive_produced_by, produced_by, directed_by etc.
At the moment, if I pass in Mike Newell, I get no results, as he isn't an actor, but a director among other things.
Any ideas as to how to do this in a single query? I am essentially looking for optional types. e.g. find Mike Newell in /film/actors or /film/directed_by etc.
What documentation have you consulted so far? You can use the |= operator to specify multiple IDs, types, etc. You can use the optional: true clause to make a value optional for a property (otherwise, it'll exclude entities which don't have a value for that property).
What have you tried so far and found lacking?
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
}]
}]
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.
I'm wondering if it is possible to get all info about a specific date from Freebase.
I can easily retrieve info about a date giving a specific topic, for example, to grab all persons of interest who were born on a specific date:
[{
"type":"/people/person",
"limit":1000,
"sort":"name",
"name":null,
"guid":null,
"timestamp":null,
"/people/person/date_of_birth":"1955-02-24"
}]
Is it possible to grab all types? I'm after things like people born on that date (which I have), major events (start of a war, assassination of a person of interest, etc), and so on.
Essentially I want to match all fields that are dates and return the full information about that entry, regardless of type.
Reflection is what you need here:
[{
"/type/reflect/any_value": [{
"type": "/type/datetime",
"value": "1955-02-24",
"link": {
"source": {
"id": null
},
"master_property": null
}
}]
}]
A couple of notes on that: the MQL manual I've linked to is somewhat bitrotted in its details but is still the best documentation that exists on MQL. Secondly, there's what I'm pretty sure is in MQL bug if you use "*": null or more specifically "target_value": null in the link clause above which makes it ignore the outer value you specified... so don't do that :-)
Let's say I want to get all movies in which at least two (different) actors called "John" played:
Example query:
[{
"type":"/film/film",
"name":null,
"limit":10,
"/film/film/initial_release_date":"2005"
"starring":[{
"a:actor": [{
"type": "/film/actor",
"name": null,
"name~=": "John",
}],
"b:actor": [{
"type": "/film/actor",
"name": null,
"name~=": "John",
}]
}]
}]
If you run the example query, you will see that it will list movies with only one "John" in them. How can I fix my query to exclude these results with duplicated children?
In general, you'll have to do the filtering client-side; queries in MQL are "tree-like" in that one part of the query can't refer to another part rather than being a generic graph.
In this case, you could look for films which have more than one "John" acting in them; however, MQL doesn't allow you to filter on a derived property like "count", so the best you can do is to reverse sort based on the count and then just stop processing as soon as you hit the first entry with "count": 1. However, that query times out if you remove the fixed 1935 release date (sorting in MQL kills performance), so you're probably stuck with just simple client-side filtering.