I query for ID's belonging to a , after that (extracting IDs with PHP), I query foreach ID what CATEGORY, it is in and whats its name: Now the question is, if it is possible to merge both:
"Query for CATEGORIES (and name of given IDs) of a given "
[1] ID an DOMAIN of ,
{
"domid":{
"query":[{
"name":null,
"name~=":"",
"type":[{
"domain":null,
"id":null,
"name":null,
"type":"/type/type"
}]
}]
}
}
[2] myIdForKeyword) to ask for CATEGORY of it,{
"category":{
"query":[{
"/type/type/domain":{
"/type/reflect/any_reverse":[{
"name":null,
"type":"/freebase/domain_category"
}],
"name":null
},
"id":"myIdForKeyword",
"name":null
}]
}
} Here’s how I built it up.
Query for instances of (literally) “keyword” and their types (with a limit, just for testing):{
"someids" : {
"query" : [
{
"limit" : 5,
"name" : null,
"name~=" : "keyword",
"type" : [
{
"id" : null
}
]
}
]
}
} But since we are primarily interested in the types, turn the query inside-out (here the limits aren’t for testing, they are because we only need at least one instance at each level, and help the query run faster):
{
"someids" : {
"query" : [
{
"id" : null,
"instance" : [
{
"limit" : 1,
"name" : null,
"name~=" : "keyword"
}
],
"type" : "/type/type"
}
]
}
}
Now let’s find the domains of those types — but while we’re at it, let’s turn that inside-out, too:
{
"someids" : {
"query" : [
{
"id" : null,
"type" : "/type/domain",
"types" : [
{
"instance" : [
{
"limit" : 1,
"name" : null,
"name~=" : "keyword"
}
],
"limit" : 1
}
]
}
]
}
} Now, what categories hold those domains?
{
"someids" : {
"query" : [
{
"domains" : [
{
"limit" : 1,
"type" : "/type/domain",
"types" : [
{
"instance" : [
{
"limit" : 1,
"name" : null,
"name~=" : "keyword"
}
],
"limit" : 1
}
]
}
],
"id" : null,
"name" : null,
"type" : "/freebase/domain_category"
}
]
}
} The answer is “System” and “Arts & Entertainment.”
Search Help Center
Discussions
There are no conversations on this topic. Would you like to start one?
Start the Discussion »- Building Bases
- Creating Schemas
-
Developing Applications
- An Introduction to Freebase Application Development
- Playing in the Sandbox
- Freebase Programming Libraries and Tools
- Data Dump FAQ
- Using the Query Editor
- The Complete Metaweb Query Language (MQL) Reference Guide
- MQL Cheatsheet
-
The MQL Cookbook
- Get data as of a specific time
- Read properties of a type
- values vs name/id
- Incoming links
- Any topics with a specific date
- Wikipedia article text
- Retrieve the Wikipedia URL for an object with a GUID
- Find distinct co-types
- Creating relationships with the connect directive
- Mark for deletion
- Sort by index and timestamp
- Traversing Through Non-Reversed Properties
- Combine queries
- Perform transitive queries
- Freebase API Reference
- Application Developer Tips
- The Acre Hosted Development Environment
- Introduction to the Metaweb Javascript Template Language (MJT)
- Freebase Community