Flags and Lollipops

Tuesday, February 19, 2008

Uh, lazyweb...?

Update: Thanks, universally helpful lazyweb!

I know it was only a month ago that you were invoked here last. But... Freebase. It's killing me (I was inspried to finally build something using it by Pierre, whose examples I have sadly failed to adapt :( ).

What MQL can I use to get *all* of the information about *all* people with profession of 'author'?

I have



{
"query" : [
{
"*" : [
{}
],
"guid" : null,
"limit" : 5,
"name" : null,
"profession" : "author",
"type" : "/people/person"
}
]
}

(thanks to Pierre for pointing out a syntax error here originally, oops)

Which should list all of the properties for 5 authors, right? But I only see properties from the /people/person schema.

How do I get all the author properties too?

I ended up using the MQL in Pierre's second comment to get a list of GUIDs for all authors (having changed the limit to 10k) then iterated over them getting all of the properties from /people/person (D.O.B, nationality...), /book/author (list of books) and /common/type (image, article) in three different calls (oy). It works, though - again, as Pierre suggests. ;)

There is a way to get everything in one MQL call, though, as Alf says:

{
"query" : [
{
"*" : null,
"/book/author/books" : [
{
"*" : null
}
],
"/common/topic/article" : [
{
"*" : null
}
],
"/common/topic/image" : [
{
"*" : null
}
],
"limit" : 5,
"profession" : "author",
"type" : "/people/person"
}
]
}

The disadvantage to this is that it's a lot of data to get in one go (considering there are thousands of authors each with lots of books)... I guess that's where paging through the results would come in (as Brendan correctly predicts).


And finally, for future reference.... skud points out that the mailing list is here.

Comments and trackbacks Feel free to post your comments Blogger Pierre Lindenbaum Blogger Stew Blogger Pierre Lindenbaum Blogger Stew Anonymous alf Blogger Pierre Lindenbaum Blogger Skud Blogger Brendan Blogger Skud . This post has trackbacks.

Trackbacks:

9 Comments:

At February 19, 2008 2:44 PM, Blogger Pierre Lindenbaum said...

You got an error in your query , you forgot the braces:

{
"query" : [
{
"*" : [
{}
],
"guid" : null,
"limit" : 5,
"name" : null,
"profession" : "author",
"type" : "/people/person"
}
]
}

now the code returned is "code" : "/api/status/ok",

 
At February 19, 2008 2:50 PM, Blogger Stew said...

Whoops, thanks Pierre.

Any idea about the properties-from-other-schemas issue?

 
At February 19, 2008 2:54 PM, Blogger Pierre Lindenbaum said...

Hi again stew,
If I understood what you want, I think the correct query should be:

{
"query" : [
{
"*" : null,
"a:type" : "/book/author",
"b:type" : "/people/person",
"limit" : 5
}
]
}

see "AND queries" at http://www.freebase.com/view/9202a8c04000641f800000000544e13e#id2616133

Pierre

 
At February 19, 2008 3:39 PM, Blogger Stew said...

Yes! Well, at least, almost. Where are the list of books that they've published, their photo, etc...?

 
At February 19, 2008 3:57 PM, Anonymous alf said...

{
"query" : [
{
"*" : null,
"/book/author/books" : [
{
"*" : null
}
],
"limit" : 5,
"profession" : "author",
"type" : "/people/person"
}
]
}

 
At February 19, 2008 3:58 PM, Blogger Pierre Lindenbaum said...

See my blog entry, the method I choose was to loop over each type for each guid (may be not the best way but it worked fine):

{
"query" : [
{
"*" : null,
"guid" : "#9202a8c04000641f80000000000207fd",
"type" : "/book/author"
}
]
}

to get the picture, I used the following method: see http://code.google.com/p/lindenb/source/browse/trunk/src/java/org/lindenb/tool/metaweb/Metaweb01.java
lines 959 -> 967 -> 1010

 
At February 20, 2008 1:13 AM, Blogger Skud said...

Not an answer as such, but are you on the Freebase developers' mailing list? This stuff is bread and butter to them.

http://lists.freebase.com/mailman/listinfo/developers

K.

 
At February 20, 2008 7:14 PM, Blogger Brendan said...

I predict the next thing you're going to want to know is, how do I get more than 5 authors? You will need to request a cursor, which you can then use in a subsequent request to get the next 5 authors, grab the new cursor, request the next 5, etc.

http://www.freebase.com/view/9202a8c04000641f800000000544e139#cursors

 
At February 20, 2008 7:21 PM, Blogger Skud said...

Technically, the easier way to get more than 5 authors is to remove the "limit" from the query ;)

 

Post a Comment

<< Home


See all posts from: July 2005 August 2005 September 2005 October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 September 2006 October 2006 November 2006 December 2006 January 2007 February 2007 March 2007 April 2007 May 2007 June 2007 July 2007 August 2007 October 2007 November 2007 December 2007 January 2008 February 2008 March 2008