复杂的 CouchDb 视图
我的数据库中有以下文档:
{
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您应该使用 RegExp 对象 作为关键字和 与
group_level
聚合。I think you should use RegExp objects as keywords and aggregate with
group_level
.