复杂的 CouchDb 视图

发布于 2024-10-28 19:02:26 字数 647 浏览 1 评论 0原文

我的数据库中有以下文档:

{
  id: 1,
  text: 'Hello I had a big grannysmith apple today and a big pear'
},
{
  id: 2,
  text: 'Hello I had a big apple today only'
},
{
  id: 3,
  text: 'Hello I had a big apple today, a big pear yesterday and a big orange today'
}

我的视图需要返回文本中特定关键字的聚合计数,但关键字的查找方式需要“宽松”。我的视图应该返回如下内容:

{
  'grannysmith apple' : 3,
  'pear': 2,
  'orange': 1
}

如您所见,我已经数了 苹果 3 次,即使标签是 'grannysmith apple',我仍然想拿起任何也出现了'apples'

这可能吗?或者我应该在插入 CouchDb 之前执行此操作?我正在使用 Node.js 执行保存 - 我应该在 Node.js 中执行此操作吗?

提前致谢!

I have the following documents in a database:

{
  id: 1,
  text: 'Hello I had a big grannysmith apple today and a big pear'
},
{
  id: 2,
  text: 'Hello I had a big apple today only'
},
{
  id: 3,
  text: 'Hello I had a big apple today, a big pear yesterday and a big orange today'
}

My view needs to return an aggregated count of specific keywords in the text, but the keywords need to be 'loose' on how they found. My view should return something like this:

{
  'grannysmith apple' : 3,
  'pear': 2,
  'orange': 1
}

As you can see I have counted apples 3 times even though the tag is for 'grannysmith apple', I still want to pick up any occurrences of 'apples' as well.

Is this possible? Or should I be doing this before I insert into CouchDb? I'm using node.js to perform the saving - should I do it in node.js?

Thanks in advance!

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

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

发布评论

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

评论(1

心房的律动 2024-11-04 19:02:26

我认为您应该使用 RegExp 对象 作为关键字和 group_level 聚合。

I think you should use RegExp objects as keywords and aggregate with group_level.

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