问题
Following the Freebase docs on Envelope Parameters, running
{
"cursor":true,
"query":[{
"type":"/music/album",
"artist":"The Police",
"name":null,
"limit":10
}]
}
results in error "Key cursor is a reserved word"
as @Domenic notes.
What's going wrong?
Edit 1
So this query without a cursor works but this one doesn't because cursor was a variable name not a string enclosed in quotes.
As a user it makes sense to type the broken version of "cursor"
because the read parameter type table has both query
and "cursor"
as type: string
, and query
errors out if your enclose it in quotes as "query"
However, even enclosing "cursor"
in quotes still doesn't work: it results in the same data for every query.
回答1:
It looks like this may be another case of the query editor being too smart and fixing things for us. If you copy and paste the query above into the query editor and press Run you will get this error as you reported:
{
"code": "/api/status/error",
"messages": [{
"code": "/api/status/error/mql/type",
"info": {
"expected_type": "/type/object",
"property": "cursor"
},
"message": "Key cursor is a reserved word",
"path": "",
"query": {
"cursor": true,
"error_inside": ".",
"query": [{
"artist": "The Police",
"limit": 10,
"name": null,
"type": "/music/album"
}]
}
}],
"status": "200 OK",
"transaction_id": "cache;cache03.p01.sjc1:8101;2011-11-04T17:42:13Z;0057"
}
But then if you click on the permalink to that query it changes it to this query and automatically sets the cursor property to true.
[{
"type": "/music/album",
"artist": "The Police",
"name": null,
"limit": 10
}]
This happens because the MQL read service expects a query to be nested inside a query envelope but the query editor just takes the query you give it and automatically wraps it in an appropriate query envelope for you.
In the new version of the MQL read service, we've done away with the query envelope and now cursor is just a parameter on the HTTP GET request.
来源:https://stackoverflow.com/questions/8003317/freebase-key-cursor-is-a-reserved-word