开发者

Freebase Query with "JOINS"

开发者 https://www.devze.com 2023-02-02 04:38 出处:网络
... Yeah, yeah, I know traditional joins don\'t exist.I actually like the freebase query methodology in theory, just having a little trouble getting it to actually work for me : )

... Yeah, yeah, I know traditional joins don't exist. I actually like the freebase query methodology in theory, just having a little trouble getting it to actually work for me : )

Anyone have a dumb-simple example of getting Freebase data via MQL that pulls from two different "tables"? In particular, I'm trying to get automotive data... so for example, pulling fields from both /automotive/model_year and /automotive/trim_level.

I've read the documentation (for hours开发者_开发百科 actually). There's a distinct possibility that I'm looking right at such an example somewhere and just not seeing it because my OLTP brain just doesn't comprehend what it's seeing.

* Note * ... that the two "types" I'm working with above are siblings, not parent/child. Does freebase even allow joining data between sibling nodes... I see examples of queries pulling from parent/child, but not from siblings I don't think (or I've overlooked them).


Basically, could you not just restrict the queries according to the user's input?

When the user selects the year, you get all makes that have a matching model year:

[{
  "model_s": [{
    "model_years": [{
      "year": [{
        "type":    "/type/datetime",
        "value<":  "2010", // User input
        "value>=": "2009" // User input
      }],
      "type": "/automotive/model_year"
    }],
    "type": "/automotive/model"
  }],
  "id":   null,
  "name": null,
  "type": "/automotive/make"
}]​

If the make is selected and you need the models for that make and year:

[{
  "model_years": [{
    "year": [{
      "type":    "/type/datetime",
      "value<":  "2010", // User input from above
      "value>=": "2009" // User input from above
    }],
    "type": "/automotive/model_year"
  }],
  "id":   null,
  "name": null,
  "type": "/automotive/model",
  "make": [{
    "id":   "/en/volkswagen", // User input
    "type": "/automotive/make"
  }]
}]​

Or did I just not understand your problem correctly?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号