Search code examples
freebasemql

Freebase - query media_common on book_edition to get /book/book?


a complete beginner with freebase here, trying to understand how to make a query to find a /book/book by /book_edition/media_common/cataloged_instance/isbn13.

I tried this query and got this error: Type /book/book_edition does not have property media_common:

[{
  "type": "/book/book",
  "editions": [{
    "media_common": [{
      "cataloged_instance": [{
        "isbn13": "9780812519112" //example isbn13 from ender's game - https://www.freebase.com/m/04v8gr6
      }]
    }]
  }],
  "id": null
}]

EDIT: this is the query I used to get the deprecated ISBN field on book_edition

[{
  "type": "/book/book",
  "editions": [{
    "ISBN": "0312932081"
  }],
  "id": null
}]

Solution

  • The property is actually /media_common/cataloged_instance/isbn13 which you can discover by exploring the schema. Because it's from a different type than the expected type of /book/book/editions (which is /book/book_edition you need to use the fully qualified name. Ditto for the author property I added to the query below.

    [{
      "type": "/book/book",
      "editions": [{
        "/media_common/cataloged_instance/isbn13": "9780812519112"
      }],
      "id": null,
      "name": null,
      "/book/written_work/author": null
    }]
    

    without using the shorthand notation that allows us to drop type prefixes on property names, this query would look like:

    [{
      "/book/book/editions": [{
        "/media_common/cataloged_instance/isbn13": "9780812519112"
      }],
      "/type/object/id": null,
      "/type/object/name": null,
      "/book/written_work/author": null
    }]
    

    The expansion of the property names to their fully qualified versions gets done mechanically by the query processor without any real knowledge of the schema. Conversely, graph traversal treats the property names as opaque strings.