简体   繁体   中英

Traversing the Freebase Graph

I'm trying to fetch multiple levels of influence relationships from a particular person. Roughly, this query explains what I'm trying to accomplish

{ "id" : "/en/george_orwell",
  "name" : null,
  "type" : "/influence/influence_node",
  "influenced": [{"id": null,"name" : null,
                  "type" : "/influence/influence_node",
                   "influenced": [{"id": null,"name" : null,
                                   "type" : "/influence/influence_node",
                                   "influenced": [{"id": null,"name" : null}],
                                   "influenced_by": [ { "id": null, "name" : null}] }],
                  "influenced_by": [ {"id": null,"name" : null,
                                   "type" : "/influence/influence_node",
                                   "influenced": [{"id": null,"name" : null}],
                                   "influenced_by": [ { "id": null, "name" : null}] }],
  "influenced_by": [{"id": null,"name" : null,
                  "type" : "/influence/influence_node",
                  "influenced": [{"id": null,"name" : null,
                                   "type" : "/influence/influence_node",
                                   "influenced": [{"id": null,"name" : null}],
                                   "influenced_by": [ { "id": null, "name" : null}] }],
                  "influenced_by": [ {"id": null,"name" : null,
                                   "type" : "/influence/influence_node",
                                   "influenced": [{"id": null,"name" : null}],
                                   "influenced_by": [ { "id": null, "name" : null}] }] }

Is there any efficient way of traversing the Freebase graph using MQL?

I assume you want to get influenced and influenced_by for a given number of plies out? No it's not possible to do this in mql, it would require some sort of recursion and self-referencing.

However, you can pass multiple ids using this syntax [{ 'id|=': ['id1', 'id2', ...] }]

In that way you can get the list of people from running the query the first time given a seed, and then re-run the query to crawl the graph for any given id selected.

If this is not aimed to be done interactively (by a person) then you should probably use the freebase data dumps to pre-calculate the whole thing offline.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM