<span class="Apple-style-span" style="font-family: arial, sans-serif;"><span class="Apple-style-span" style="font-size: small;">Hi Guys,</span></span><div><span class="Apple-style-span" style="font-family: arial, sans-serif;">
<span class="Apple-style-span" style="font-size: small;"><br class="webkit-block-placeholder"></span></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif;"><span class="Apple-style-span" style="font-size: small;">
Tim - thanks for the info, I'll look into MQL Cursors.</span></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif;"><span class="Apple-style-span" style="font-size: small;"><br class="webkit-block-placeholder">
</span></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif;"><span class="Apple-style-span" style="font-size: small;">Chris - I checked to see if the query produced was the same and I believe it is. This is what PHP outputs:
</span></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif;"><span class="Apple-style-span" style="font-size: small;"><br class="webkit-block-placeholder"></span></span></div><div><span class="Apple-style-span" style="font-size: small;">
<span class="Apple-style-span" style="font-family: 'courier new', monospace;">{"qname":{"query":[{"\/common\/topic\/image":[{"optional":true,"id":null}],"type":"\/cvg\/computer_videogame","name":null,"id":null,"sort":"name","release_date":[],"cvg_genre":[],"versions":{"platform":{"id":null,"name":null,"name~=":"Xbox 360"}},"limit":150}]}}
</span></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif;"><span class="Apple-style-span" style="font-size: small;"><br class="webkit-block-placeholder"></span></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif;">
<span class="Apple-style-span" style="font-size: small;">I ran the above query in freebase and it produced results. This is the PHP that passes my query through:</span></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif;">
<span class="Apple-style-span" style="font-size: small;"><br class="webkit-block-placeholder"></span></span></div><div><span class="Apple-style-span" style="font-family: Times; font-size: 16px;"><div><span class="Apple-style-span" style="font-size: small;">
<span class="Apple-style-span" style="font-family: 'courier new', monospace;">// Put the query into an envelope object</span></span></div><div><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: 'courier new', monospace;">
$envelope = array("qname" => array("query" => $queryobj));</span></span></div><div><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: 'courier new', monospace;">
<br class="webkit-block-placeholder"></span></span></div><div><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: 'courier new', monospace;">// Serialize the envelope object to JSON text
</span></span></div><div><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: 'courier new', monospace;">$querytext = $this->json->encode($envelope);</span>
</span></div></span><div><br class="webkit-block-placeholder"></div><div>Thanks,</div><div>Chris</div><br><div class="gmail_quote">On Jan 3, 2008 12:25 AM, Chris Eppstein <<a href="mailto:chris@eppsteins.net">chris@eppsteins.net
</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I wonder if the problem is just that the query isn't being placed<br>within the request envelope. That would make it work in the editor but
<br>not via code. The request you send via mqlread should look like this<br>{ 'qname' : { 'query' : query_in_the_query_editor }}<br><br>This was a gotcha for me on a couple of occasions until I abstracted<br>
it away.<br><font color="#888888"><br>-chris<br></font><div><div></div><div class="Wj3C7c"><br><br>On Jan 2, 2008, at 2:22 PM, Tim Kientzle wrote:<br><br>> If you get no results without the limit, it's probably timing out on
<br>> the server.<br>><br>> You'll need to use a cursor to request "pages" of data at a time. On<br>> <a href="http://freebase.com" target="_blank">freebase.com</a>,<br>> search for "MQL Cursors" and you'll get a few useful hits, including
<br>> some examples:<br>><br>> <a href="http://www.freebase.com/view/search?limit=30&start=0&query=mql+cursor" target="_blank">http://www.freebase.com/view/search?limit=30&start=0&query=mql+cursor
</a><br>><br>> You should probably start with the documentation here:<br>><br>> <a href="http://www.freebase.com/view/guid/9202a8c04000641f800000000544e139" target="_blank">http://www.freebase.com/view/guid/9202a8c04000641f800000000544e139
</a><br>><br>><br>><br>> On Jan 2, 2008, at 1:12 PM, Chris Mahon wrote:<br>><br>>> Hi Chris,<br>>><br>>> Thanks for the reply. Starting to make more sense, I can't see how I<br>>> would use games_on_this_platform then?
I.E. what can I do with it?<br>>> My query was the same as on the Query Builder/Editor which did<br>>> return results so it was odd that PHP did not. Anyway, I've made<br>>> good progress and now have results coming back!
<br>>><br>>> One quick question though. I am adding a limit to my query, above<br>>> the default 100. However when I do this it does not return results<br>>> for my query. If I take the limit out, I get results. Any ideas? Is
<br>>> there a way of getting it to return ALL matches without limit?<br>>><br>>> Query is now as follows:<br>>><br>>> $q2 = array(array("/common/topic/image" => array(array("optional" =>
<br>>> true, "id" => null)),<br>>> "type" => "/cvg/computer_videogame",<br>>> "name" => null,
<br>>> "id" => null,<br>>> "sort" => "name",<br>>> "release_date" => array(),
<br>>> "cvg_genre" => array(),<br>>> "versions" => array("platform" => array("id" => null, "name"
<br>>> => null, "name~=" => "Xbox 360")),<br>>> "limit" => 150<br>>> ));<br>>><br>>> Cheers,<br>>> Chris
<br>>><br>>> On Jan 1, 2008 5:53 PM, Christopher R. Maden <<a href="mailto:crism@metaweb.com">crism@metaweb.com</a>><br>>> wrote:<br>>> Chris Mahon <<a href="mailto:darthmahon@gmail.com">darthmahon@gmail.com
</a>> wrote:<br>>>> I'm currently building a search page for computer games and have<br>>> come across<br>>>> some teething problems whilst using freebase.<br>>>><br>>>> This is the query I based that on from within the freebase query
<br>>> builder:<br>>>><br>>>> [{<br>>>> "type":"/cvg/cvg_platform",<br>>>> "games_on_this_platform":[{ "game":[{ "name":null }] }],
<br>>>> "name":"Xbox 360"<br>>>> }]<br>>><br>>> Happy new year, Chris. The problem with using foreach on the result<br>>> of that query is that it returns a single thing: the platform called
<br>>> "Xbox 360." Now, it has a number of games on that platform, but the<br>>> root of the query is just the platform itself.<br>>><br>>> You can turn the query inside-out, to find games whose platform is
<br>>> the Xbox 360, or you can iterate over the games on that platform,<br>>> instead of iterating over the platform itself.<br>>><br>>> ~Chris<br>>> --<br>>> Christopher R. Maden<br>>> Data Architect
<br>>> Metaweb Technologies, Inc.<br>>> <URL: <a href="http://www.metaweb.com/" target="_blank">http://www.metaweb.com/</a> ><br>>> _______________________________________________<br>>> Developers mailing list
<br>>> <a href="mailto:Developers@freebase.com">Developers@freebase.com</a><br>>> <a href="http://lists.freebase.com/mailman/listinfo/developers" target="_blank">http://lists.freebase.com/mailman/listinfo/developers
</a><br>>><br>>> _______________________________________________<br>>> Developers mailing list<br>>> <a href="mailto:Developers@freebase.com">Developers@freebase.com</a><br>>> <a href="http://lists.freebase.com/mailman/listinfo/developers" target="_blank">
http://lists.freebase.com/mailman/listinfo/developers</a><br>><br>> _______________________________________________<br>> Developers mailing list<br>> <a href="mailto:Developers@freebase.com">Developers@freebase.com
</a><br>> <a href="http://lists.freebase.com/mailman/listinfo/developers" target="_blank">http://lists.freebase.com/mailman/listinfo/developers</a><br><br>_______________________________________________<br>Developers mailing list
<br><a href="mailto:Developers@freebase.com">Developers@freebase.com</a><br><a href="http://lists.freebase.com/mailman/listinfo/developers" target="_blank">http://lists.freebase.com/mailman/listinfo/developers</a><br></div>
</div></blockquote></div><br></div>