Using the Query Editor

The Query Editor is a tool to help you formulate and see the results of Metaweb Query Language (MQL) queries. You can use the Query Editor in conjunction with the MQL Reference Guide to teach yourself MQL, test queries for use in hosted Acre or client-side applications, or to just get information directly from Freebase. You can also use the Query Editor to perform write operations that insert new information into the Freebase database.

You can access the Query Editor by clicking Query Editor in the Developer's Toolbar (press F8 on your keyboard to open the toolbar if it's not already open), or by clicking the Query Editor link on the Apps page.

Features

  • Automatic Formatting and Debugging of MQL queries - the format feature checks your query for correct syntax, provides error information, and orders the elements of your query for greatest processing efficiency.
  • Syntax Highlighting - provides an easy way to identify and debug the elements of your query.
  • Permalink and mqlWrite URIs - generate permanent URL links for your queries, or see how they would be constructed for use with the mqlWrite API web service.
  • JSON or Tree Views of Results - view your results as a JSON object or in a collapsible/expandable tree view.
  • Example Queries - a large library of example queries that you can use for learning MQL or adapt to your own needs.

A Sample Query

You can try out the Query Editor with this simple query that asks for the name of the musical group associated with the id /en/the_police :

     {
"query":{
"id":/en/the_police",
"name":null
}
}
  1. Open the Query Editor by pressing F8 to open the Developer's Toolbar, then click Query Editor .
  2. Copy the sample query and paste it into the left-hand window.
  3. The Query Editor automatically highlights the syntax elements of the query. A very useful feature of the syntax highlighting is the ability to check matching {} elements. Click on a { and its matching } will be highlighted in red.
  4. Click format and the Query Editor will format the query. In this case, it removes the query element and the corresponding braces, since these aren't necessary when submitting a query in Query Editor.
    • If you want to see what your query looked like before it was formatted, click Undo . You can step backwards through multiple undo levels to see changes to your query.
    • If you want to see how query editor handles syntax errors, remove an element from your query and click format . You'll see an error message at the top of the query window.
  5. After you've formulated your query, click read . The JSON result of your query is displayed in the right-hand window. Click Tree View to see the hierarchical view of your results. If you want to see the response statistics for Freebase, as well as the transaction ID (TID) for your query, click stats just below the results window.
    • You can also use the keyboard shortcut of CNTRL + RTN to perform the read operation.
  6. Click mqlread to generate a mqlRead command to the Freebase API. The mqlRead query will appear in your URL window and an HTML text/plain result will appear in your browser window.
  7. Click permalink to generate a permanent link to the query. You can send this link to another user, embed it in a web page, or use it in any way that you would normally use a web link.

If you want to experiment further with Query Editor and MQL, there are several examples, including those used in the MQL Reference Guide , available by clicking examples just below the query window.


Search Help Center

Discussions

There are no conversations on this topic. Would you like to start one?

Start the Discussion »