You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Hank Knight <hk...@gmail.com> on 2013/10/11 19:56:57 UTC

CouchDB: Using "OR" in Queries

This allows my to find all results where the key equals "GOLD":
http://example.com/abc/_design/iws/_view/q?key=%GOLD%22

This allows my to find all results where the key equals "SILVER":
http://example.com/abc/_design/iws/_view/q?key=%SILVER%22

This allows my to find all results where the key equals "BRONZE":
http://example.com/abc/_design/iws/_view/q?key=%BRONZE%22

How can I get results with a single query where the key equals GOLD or
SILVER but not BRONZE?

Re: CouchDB: Using "OR" in Queries

Posted by Stanley Iriele <si...@gmail.com>.
Couldn't you use an http Post with the keys array field for that?

{keys: [SILVER, GOLD]}
On Oct 11, 2013 11:03 AM, "Robert Newson" <rn...@apache.org> wrote:

> http://example.com/abc/_design/iws/_view/q?startkey="GOLD"&endkey="SILVER"
>
> This assumes you don't have other key values inbetween.
>
> B.
>
>
> On 11 Oct 2013, at 13:56, Hank Knight <hk...@gmail.com> wrote:
>
> > This allows my to find all results where the key equals "GOLD":
> > http://example.com/abc/_design/iws/_view/q?key=%GOLD%22
> >
> > This allows my to find all results where the key equals "SILVER":
> > http://example.com/abc/_design/iws/_view/q?key=%SILVER%22
> >
> > This allows my to find all results where the key equals "BRONZE":
> > http://example.com/abc/_design/iws/_view/q?key=%BRONZE%22
> >
> > How can I get results with a single query where the key equals GOLD or
> > SILVER but not BRONZE?
>
>

Re: CouchDB: Using "OR" in Queries

Posted by Robert Newson <rn...@apache.org>.
http://example.com/abc/_design/iws/_view/q?startkey="GOLD"&endkey="SILVER"

This assumes you don't have other key values inbetween.

B.


On 11 Oct 2013, at 13:56, Hank Knight <hk...@gmail.com> wrote:

> This allows my to find all results where the key equals "GOLD":
> http://example.com/abc/_design/iws/_view/q?key=%GOLD%22
> 
> This allows my to find all results where the key equals "SILVER":
> http://example.com/abc/_design/iws/_view/q?key=%SILVER%22
> 
> This allows my to find all results where the key equals "BRONZE":
> http://example.com/abc/_design/iws/_view/q?key=%BRONZE%22
> 
> How can I get results with a single query where the key equals GOLD or
> SILVER but not BRONZE?


Re: CouchDB: Using "OR" in Queries

Posted by Ryan Ramage <ry...@gmail.com>.
see http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options

Unfortunately, you cant do a NOT query. you would either have to post
process with a list function, or on the client side.

Since 0.9 you can also issue *POST* requests to views where you can send
the following JSON structure in the body:

{"keys": ["key1", "key2", ...]}



On Fri, Oct 11, 2013 at 12:09 PM, svilen <az...@svilendobrev.com> wrote:

> wasn't it
> ...?keys=[list]
>
>
> n Fri, 11 Oct 2013 14:56:57 -0300
> Hank Knight <hk...@gmail.com> wrote:
>
> > This allows my to find all results where the key equals "GOLD":
> > http://example.com/abc/_design/iws/_view/q?key=%GOLD%22
> >
> > This allows my to find all results where the key equals "SILVER":
> > http://example.com/abc/_design/iws/_view/q?key=%SILVER%22
> >
> > This allows my to find all results where the key equals "BRONZE":
> > http://example.com/abc/_design/iws/_view/q?key=%BRONZE%22
> >
> > How can I get results with a single query where the key equals GOLD or
> > SILVER but not BRONZE?
>

Re: CouchDB: Using "OR" in Queries

Posted by Robert Newson <rn...@apache.org>.
That'll work too, though keys for GET is fairly recent iirc, you might have to POST for older versions.

"OR" is easy enough, it's "AND" that's tricky (and why I wrote couchdb-luceneā€¦)

B.

On 11 Oct 2013, at 14:09, svilen <az...@svilendobrev.com> wrote:

> wasn't it
> ...?keys=[list]
> 
> 
> n Fri, 11 Oct 2013 14:56:57 -0300
> Hank Knight <hk...@gmail.com> wrote:
> 
>> This allows my to find all results where the key equals "GOLD":
>> http://example.com/abc/_design/iws/_view/q?key=%GOLD%22
>> 
>> This allows my to find all results where the key equals "SILVER":
>> http://example.com/abc/_design/iws/_view/q?key=%SILVER%22
>> 
>> This allows my to find all results where the key equals "BRONZE":
>> http://example.com/abc/_design/iws/_view/q?key=%BRONZE%22
>> 
>> How can I get results with a single query where the key equals GOLD or
>> SILVER but not BRONZE?


Re: CouchDB: Using "OR" in Queries

Posted by svilen <az...@svilendobrev.com>.
wasn't it
...?keys=[list]


n Fri, 11 Oct 2013 14:56:57 -0300
Hank Knight <hk...@gmail.com> wrote:

> This allows my to find all results where the key equals "GOLD":
> http://example.com/abc/_design/iws/_view/q?key=%GOLD%22
> 
> This allows my to find all results where the key equals "SILVER":
> http://example.com/abc/_design/iws/_view/q?key=%SILVER%22
> 
> This allows my to find all results where the key equals "BRONZE":
> http://example.com/abc/_design/iws/_view/q?key=%BRONZE%22
> 
> How can I get results with a single query where the key equals GOLD or
> SILVER but not BRONZE?