如何做到“不等于”?在couchdb中? [英] How to do "Not Equals" in couchdb?

查看:83
本文介绍了如何做到“不等于”?在couchdb中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我想知道建模文档和/或映射函数的最佳方法是什么,这些方法允许我进行不等于查询。

Folks, I was wondering what is the best way to model document and/or map functions that allows me "Not Equals" queries.

例如,我的文档

1. { name : 'George' }
2. { name : 'Carlin' }

I想要触发一个查询,以返回名称不等于 John的每个文档。

I want to trigger a query that returns every documents where name not equals 'John'.


  • 注意:我手头上没有所有可能的名字。因此查询中的参数可以是任意随机文本,例如我的示例中的约翰。

推荐答案

In short: there is no easy solution.

您有四个选择:


  • 发送多范围查询

  • 使用服务器端列表功能过滤视图响应

  • 使用CouchDB插件

  • 使用芒果查询语言

  • sending a multi range query
  • filter the view response with a server-side list function
  • using a CouchDB plugin
  • use the mango query language

发送多范围查询

您可以请求具有由startkey和endkey定义的两个范围的视图。您必须选择范围,以便不需要键 John

You can request the view with two ranges defined by startkey and endkey. You have to choose the range so, that the key John is not requested.

不幸的是,您必须找到某个地方存在的提交请求,并使用它来编译CouchDB。它未包含在官方资料中。

Unfortunately you have to find the commit request that somewhere exists and compile your CouchDB with it. Its not included in the official source.

使用服务器端列表功能过滤视图响应

不是建议使用,但您可以使用列表函数,并在响应中忽略带有键 John 的行。就像您将使用JavaScript数组一样。

Its not recommended but you can use a list function and ignore the row with the key John in your response. Its like you will do it with a JavaScript array.

使用CouchDB插件

使用例如CouchDB-Lucene。 Lucene服务器具有这样的查询功能。

Create an additional index with e.g. couchdb-lucene. The lucene server has such query capabilities.

使用芒果查询语言

它包含在CouchDB 2.0中开发人员预览。尚未准备好生产,但肯定会包含在稳定版本中。

Its included in the CouchDB 2.0 developer preview. Not ready for production but will be definitely included in the stable release.

这篇关于如何做到“不等于”?在couchdb中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆