gpt4 book ai didi

arangodb - ArangoDB是否有分面搜索?

转载 作者:行者123 更新时间:2023-12-04 13:39:38 26 4
gpt4 key购买 nike

有谁知道ArangoDB是否支持多面搜索,以及与支持该功能的其他产品(例如Solr,MarkLogic)或不支持该功能的其他产品(例如Mongo)相比,性能如何?

在搜索了站点,阅读了文档并搜索了Google群组之后,我看不到任何地方讨论它。

谢谢

最佳答案

ArangoDB有一种查询语言,它支持类似分组的查询。这使您可以实现多面搜索。可以肯定的是,我们对多面搜索有相同的理解,请允许我解释一下,我认为这意味着什么。例如,您有一个产品列表。每个产品都有一些属性(例如名称,型号)和某些类别(例如制造商)。然后,我可以搜索名称或包含单词的名称。这将列出所有产品,并指出哪个类别中有多少产品。这是你的意思吗?

因此,例如:假设您的文档具有三个属性(名称,属性1,属性2)和两个类别(category1,category2):

> for (i = 0; i < 10000; i++) db.products.save({category1: i % 5, category2: i % 7, attribute1: i % 13, attribute2: i % 17, name: "Lore Ipsum " + i, productId: i})

因此一个典型的文档是:
> db.products.any()
{
"_id" : "products/8788564659",
"_rev" : "8788564659",
"_key" : "8788564659",
"productId" : 9291,
"category1" : 1,
"category2" : 2,
"attribute1" : 9,
"attribute2" : 9,
"name" : "Lore Ipsum 9291"
}

如果要搜索attribute1在2和3(包括3)之间的所有文档,则可以使用
> db._query("FOR p IN products FILTER p.attribute1 >= 2 && p.attribute1 <= 3 SORT p.name LIMIT 3 RETURN p").toArray();
[
{
"_id" : "products/7159077555",
"_rev" : "7159077555",
"_key" : "7159077555",
"productId" : 1003,
"category1" : 3,
"category2" : 2,
"attribute1" : 2,
"attribute2" : 0,
"name" : "Lore Ipsum 1003"
},
{
"_id" : "products/7159274163",
"_rev" : "7159274163",
"_key" : "7159274163",
"productId" : 1004,
"category1" : 4,
"category2" : 3,
"attribute1" : 3,
"attribute2" : 1,
"name" : "Lore Ipsum 1004"
},
{
"_id" : "products/7161633459",
"_rev" : "7161633459",
"_key" : "7161633459",
"productId" : 1016,
"category1" : 1,
"category2" : 1,
"attribute1" : 2,
"attribute2" : 13,
"name" : "Lore Ipsum 1016"
}
]

或者如果您仅对产品标识感兴趣
> db._query("FOR p IN products FILTER p.attribute1 >= 2 && p.attribute1 <= 3 SORT p.name LIMIT 3 RETURN p.productId").toArray();
[
1003,
1004,
1016
]

现在要获取有关category1的方面
>  db._query("LET l = (FOR p IN products FILTER p.attribute1 >= 2 && p.attribute1 <= 3 SORT p.name RETURN p) return [ slice(l,@skip,@count), (FOR p in l collect c1 = p.category1 INTO g return { category1: c1, count: length(g[*].p)}) ]", { skip: 0, count: 3 }).toArray()
[
[
[
{
"_id" : "products/7159077555",
"_rev" : "7159077555",
"_key" : "7159077555",
"productId" : 1003,
"category1" : 3,
"category2" : 2,
"attribute1" : 2,
"attribute2" : 0,
"name" : "Lore Ipsum 1003"
},
{
"_id" : "products/7159274163",
"_rev" : "7159274163",
"_key" : "7159274163",
"productId" : 1004,
"category1" : 4,
"category2" : 3,
"attribute1" : 3,
"attribute2" : 1,
"name" : "Lore Ipsum 1004"
},
{
"_id" : "products/7161633459",
"_rev" : "7161633459",
"_key" : "7161633459",
"productId" : 1016,
"category1" : 1,
"category2" : 1,
"attribute1" : 2,
"attribute2" : 13,
"name" : "Lore Ipsum 1016"
}
],
[
{
"category1" : 0,
"count" : 307
},
{
"category1" : 1,
"count" : 308
},
{
"category1" : 2,
"count" : 308
},
{
"category1" : 3,
"count" : 308
},
{
"category1" : 4,
"count" : 308
}
]
]
]

要向下钻取category1并将facet用于category2:
>  db._query("LET l = (FOR p IN products FILTER p.attribute1 >= 2 && p.attribute1 <= 3 && p.category1 == 1 SORT p.name RETURN p) return [ slice(l,@skip,@count), (FOR p in l collect c2 = p.category2 INTO g return { category2: c2, count: length(g[*].p)}) ]", { skip: 0, count: 3 }).toArray()
[
[
[
{
"_id" : "products/7161633459",
"_rev" : "7161633459",
"_key" : "7161633459",
"productId" : 1016,
"category1" : 1,
"category2" : 1,
"attribute1" : 2,
"attribute2" : 13,
"name" : "Lore Ipsum 1016"
},
{
"_id" : "products/7169497779",
"_rev" : "7169497779",
"_key" : "7169497779",
"productId" : 1056,
"category1" : 1,
"category2" : 6,
"attribute1" : 3,
"attribute2" : 2,
"name" : "Lore Ipsum 1056"
},
{
"_id" : "products/6982720179",
"_rev" : "6982720179",
"_key" : "6982720179",
"productId" : 106,
"category1" : 1,
"category2" : 1,
"attribute1" : 2,
"attribute2" : 4,
"name" : "Lore Ipsum 106"
}
],
[
{
"category2" : 0,
"count" : 44
},
{
"category2" : 1,
"count" : 44
},
{
"category2" : 2,
"count" : 44
},
{
"category2" : 3,
"count" : 44
},
{
"category2" : 4,
"count" : 44
},
{
"category2" : 5,
"count" : 44
},
{
"category2" : 6,
"count" : 44
}
]
]
]

为了使该搜索字符串更加用户友好,有必要用Javascript编写一些小的辅助函数。我认为支持小组 https://groups.google.com/forum/#!forum/arangodb将是他们讨论您的需求的正确地方。

关于arangodb - ArangoDB是否有分面搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22377705/

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