如何在couchdb中“不等于”?(How to do “Not Equals” in couchdb?)

系统教程 行业动态 更新时间:2024-06-14 16:57:41
如何在couchdb中“不等于”?(How to do “Not Equals” in couchdb?)

伙计们,我想知道什么是模拟文档和/或地图功能的最佳方法,它允许我“不等于”查询。

例如,我的文件是:

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

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

注意:我手头上没有所有可能的名字。 所以查询中的参数可以是任何随机文本,例如我的例子中的'John'。

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

For example, my documents are:

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

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

Note: I don't have all possible names before hand. So the parameters in query can be any random text like 'John' in my example.

最满意答案

简而言之:没有简单的解决方案。

您有四种选择:

发送多范围查询 使用服务器端列表函数过滤视图响应 使用CouchDB插件 使用芒果查询语言

发送多范围查询

您可以使用startkey和endkey定义的两个范围来请求视图。 您必须选择范围,以便不要求关键John 。

不幸的是,您必须找到某处存在的提交请求并使用它编译CouchDB。 它不包括在官方来源中。

使用服务器端列表函数过滤视图响应

它不推荐,但您可以使用列表函数,并在响应中忽略关键字John的行。 就像你将使用JavaScript数组一样。

使用CouchDB插件

使用例如couchdb-lucene创建其他索引。 lucene服务器具有此类查询功能。

使用“芒果”查询语言

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

In short: there is no easy solution.

You have four options:

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

sending a multi range query

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.

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

filter the view response with a server-side list function

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.

using a CouchDB plugin

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

use the "mango" query language

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

更多推荐

本文发布于:2023-04-13 12:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/bf6c0f5a0e7100d270527a93b515d036.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不等于   如何在   couchdb   Equals

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!