1
votes

I'm trying to use Freebase to search for multiple items at a time (using one API call). For example, if I have two items:

  1. Robert Downey, Jr.
  2. The Avengers

I want to query Freebase once and get back results for both items. Basically all I need is the mid for the top 3 or 4 results for both items. I would like to rely on Freebase's search API to provide disambiguation for topics. For example, I'd like to be able to search for "Robert Downey, Jr." with the abbreviation: "RDJ".

This is easy to do when searching one item at a time:

https://www.googleapis.com/freebase/v1/search?query=rdj

Making two calls like this would give me exactly what I'm looking for, but I would like to stay away from making these calls individually.

Reconciliation

I did run across the json-rpc call for reconciliation, and I have tried the following:

Endpoint: https://www.googleapis.com/rpc

POST body:

[
{
    "method": "freebase.reconcile",
    "apiVersion": "v1",
    "params": {
        "name": ["RDJ"],
        "key": "api_key",
        "limit":10
    }
},
{
    "method": "freebase.reconcile",
    "apiVersion": "v1",
    "params": {
        "name": ["the avengers"],
        "key": "api_key",
        "limit":10
    }
}
]

This works fairly well for Robert Downey, Jr in that I get a result of type /film/actor as I did using the search api. However, for The Avengers, I get a set of results with type /book/book rather than the 2012 film. These results don't seem to be prioritized the same way as the search results.

I tried something similar using json-rpc for a Freebase search method:

{
"method": "freebase.search",
"apiVersion": "v1",
"params": {
    "name": ["RDJ"],
    "key": "api_key",
    "limit":10
}
}

But the "freebase.search" method didn't seem to exist.

One thing to note is that I will not know the expected type of the items I am looking for before hand.

Long story short: I want the exact results the search API provides, but with multiple queries wrapped up into one call.

Am I missing something terribly simple like an OR operator for the search API?? I've been searching for days, but can't seem to find a good solution. I would appreciate any help at all!

1

1 Answers

0
votes

Why not just make two calls asynchronously? That would give you the results you need with almost no penalty in latency.

A few relevant facts:

  • The Reconcile API is still experimental. It's intended for use in reconciling against a type at a minimum and usually scoring using additional property values.

  • The Search API isn't included in the RPC mechanism because its freeform output doesn't work with the assumptions of the RPC framework. Ditto for the Topic API, although that's not really relevant here.

  • The Search API has a fairly expressive S-expression language. You don't say if you want the queries scored independently or together, but if you want them ranked jointly, you can use a filter expression like [(any name:rdj name:"The Avengers")] https://www.googleapis.com/freebase/v1/search?query=&limit=10&filter=%28any%20name:rdj%20name:%22the%20avengers%22%29