1
votes

I tried to look for answers to my problem but solutions seem to have been outdated...

I want to use cursor in MQL, with Java api, but I tried many combinations and nothing works. Also I tried to use the online query editor and with severl guesses nothing works. Here is my code:

String query = "[{\"id\":null," +
                "\"name\":null," +
                "\"type\":\"/music/artist\"," +
                "\"limit\":10"+
                "}]";
HttpTransport httpTransport = new NetHttpTransport();
HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
GenericUrl url = new GenericUrl("https://www.googleapis.com/freebase/v1/mqlread");
url.put("query", query);
url.put("key", properties.get("API_KEY"));
url.put("cursor",true);   //tried ".put("cursor",true), ("cursor",null) neither worked
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse httpResponse = interrupter.executeQuery(request);
....

And using the online query editor here: http://www.freebase.com/query I have tried the following queries: { "cursor":true, "query": { "type":"/music/artist", "name":"The Police", "album":[] } }

{
  "cursor":null,
  "query": {
  "type":"/music/artist",
  "name":"The Police",
  "album":[]
   }
}

But both give me this error:

"{ "errors": [{ "domain": "global", "reason": "invalid", "message": "Key cursor is a reserved word" }], "code": 400, "message": "Key cursor is a reserved word" }"

Any suggestions are greatly appreciated!

1

1 Answers

0
votes

Try setting the cursor to the empty string to start like this:

String query = "[{\"id\":null," +
                "\"name\":null," +
                "\"type\":\"/music/artist\"," +
                "\"limit\":10"+
                "}]";
HttpTransport httpTransport = new NetHttpTransport();
HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
GenericUrl url = new GenericUrl("https://www.googleapis.com/freebase/v1/mqlread");
url.put("query", query);
url.put("key", properties.get("API_KEY"));
url.put("cursor", "");
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse httpResponse = interrupter.executeQuery(request);