gpt4 book ai didi

couchbase - 模拟连接如何在 Couchbase 中工作?

转载 作者:行者123 更新时间:2023-12-04 23:52:09 27 4
gpt4 key购买 nike

我有一个依赖于另一个的文件。第一的:

{
"doctype": "closed_auctions",
"seller": {
"person": "person11304"
},
"buyer": {
"person": "person0"
},
"itemref": {
"item": "item1"
},
"price": 50.03,
"date": "11/17/2001",
"quantity": 1,
"type": "Featured",
"annotation": {
"author": {
"person": "person8597"
}
}

在这里你可以看到 doc.buyer.person 依赖于另一个这样的文件:
{
"doctype": "people",
"id": "person0",
"name": "Kasidit Treweek",
"profile": {
"income": 20186.59,
"interest": [
{
"category": "category251"
}
],
"education": "Graduate School",
"business": "No"
},
"watch": [
{
"open_auction": "open_auction8747"
}
]
}

我怎样才能从这两个文件中得到买家的名字?我的意思是 doc.buyer.person 与第二个文档的 ID 相关联。它是 join 并且从文档中不清楚。 http://docs.couchbase.com/couchbase-manual-2.0/#solutions-for-simulating-joins

最佳答案

好吧,首先,让我指出您引用的文档部分的第一句话(我添加了重点):

Joins between data, even when the documents being examined are contained within the same bucket, are not possible directly within the view system.



因此,对您的问题的快速回答是您有很多选择。这里有几个:
  • 假设您只需要一小部分人的名字。创建一个 View ,将 PersonId 作为键输出,将 Name 作为值输出,然后在每次需要时查询 View 以获取特定名称。
  • 假设您需要许多人参加许多拍卖。从 #1 下载基本索引的全部内容并使用 linq 执行连接。
  • 假设您需要此人的许多属性,而不仅仅是姓名。下载每个拍卖项目的 Person 文档。
  • 假设您需要来自 Auction 和 People 的一小部分。索引您需要的每个字段,包括一个类型字段,并在 Person 的键下发出所有这些字段。您将能够查询属于该人的所有项目的 View 。

  • 您在问题中链接到的示例中使用了最后一种方法。为了提高性能,有必要根据您的使用场景调整方法。

    关于couchbase - 模拟连接如何在 Couchbase 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21076688/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com