couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <rnew...@apache.org>
Subject Re: how to make queries with logical operators?
Date Sun, 27 May 2012 09:12:51 GMT
Hi Patrick,

Logical OR is straightforward in couchdb views, Martin Higman's answer
shows how to do that (though I suggest you don't emit the full doc
into your view, emit null as the value instead and use
include_docs=true).

The other suggestions are techniques that would apply if you were
attempting a logical AND operator, where you would wish to exclude
items that were missing one of two required properties. For that case
you would need to do the merge yourself or, more simply and
efficiently, use a query engine more powerful than the built-in views
(ElasticSearch and couchdb-lucene being two, as previously noted).

http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options

B.

On 27 May 2012 08:24, Martin Higham <martin@ocasta.co.uk> wrote:
> Yes, you need to write a view with a map function (
> http://wiki.apache.org/couchdb/HTTP_view_API) that emits an index of the
> doc type. e.g.
>
>    emit(doc.type, doc)
>
> and then pass an array of the types you want to retrieve as the keys query
> parameter to the view
>
> For instance if you called the design document mydesign and the view
> byType, the http request (before encoding) would be:
>
> http://localhost:5984/database/_design/mydesign/_view/byType?keys=["a","b"]
>
>
> On Sunday, 27 May 2012, Patrick Maia wrote:
>
>> Hi all, imagine I have a database that stores documents like these:
>>
>> { "type":"a", "attr1":"value1.1", "attr2":"value2.1"}
>> { "type":"a", "attr1":"value1.2", "attr2":"value2.2"}
>> { "type":"b", "attr3":"value3"}
>> { "type":"c", "attr4":"value4"}
>>
>> Is there some way to get all docs where type == "a" or  type == "b" doing
>> just one http request to couchdb?
>>
>> Thanks,
>>
>> Patrick Maia
>>

Mime
View raw message