使用“JOINS”进行 Freebase 查询

发布于 2024-10-10 03:07:27 字数 424 浏览 6 评论 0原文

...是的,是的,我知道传统的连接不存在。实际上,理论上我很喜欢 freebase 查询方法,只是在让它真正为我工作时遇到了一点麻烦:)

有人有一个通过 MQL 获取 Freebase 数据的简单示例,该数据从两个不同的“表”中提取吗?特别是,我正在尝试获取汽车数据......例如,从 /automotive/model_year 和 /automotive/trim_level 中提取字段。

我已经阅读了文档(实际上花了几个小时)。很可能我正在某处查看这样的示例,但没有看到它,因为我的 OLTP 大脑无法理解它所看到的内容。

* 注意* ...上面我正在处理的两种“类型”是兄弟姐妹,而不是父母/孩子。 freebase是否甚至允许在兄弟节点之间加入数据...我看到从父/子节点提取查询的示例,但不是从我不认为的兄弟节点(或者我忽略了它们)。

... 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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖风昔人 2024-10-17 03:07:27

基本上,您不能只根据用户的输入限制查询吗?

当用户选择年份时,您将获得具有匹配型号年份的所有品牌:

[{
  "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"
}]​

如果选择了品牌并且您需要该品牌和年份的型号:

[{
  "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"
  }]
}]​

或者我只是没有正确理解您的问题?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文