1

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

{
  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
}

正如你所看到的,即使标签是'grannysmith apple' ,我已经数了 3 次苹果,我仍然想找出任何出现的'apples'

这可能吗?或者我应该在插入 CouchDb 之前这样做吗?我正在使用 node.js 执行保存 - 我应该在 node.js 中执行吗?

提前致谢!

4

1 回答 1

0

我认为您应该使用RegExp 对象作为关键字并group_level.

于 2011-04-02T10:41:26.867 回答