You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Paul Davis <pa...@gmail.com> on 2009/03/03 16:59:01 UTC

Re: [user] Filtering with a pattern

On Tue, Mar 3, 2009 at 10:44 AM, Wout Mertens <wm...@cisco.com> wrote:
> I think in this case you'll have to create a view for each property that you
> want to filter on first.
>
> So if you want to first filter on temperature and then on endurance, I would
> emit [23.4,5,"Fe"]. I think though that "Fe" might be the actualy value so
> you might instead be emitting [23.4,5],"Fe".
>
> You can then query for startkey=[20,0]&endkey=[24,9999] and it would give
> you all elements with temperatures between 20 and 24 and all their
> endurances.
>
> Wout.
>

Wout is right on track here, but I'd suggest slightly different start keys like:

startkey=[20,null]&endkey=[24,{}]

HTH,
Paul Davis

> On Mar 3, 2009, at 3:29 PM, Manolo Padron Martinez wrote:
>
>> Hi again:
>>
>> Another newbie question.
>>
>> I have some docs in this form:
>>
>> {
>>  "Temperature":23.4,
>>  "Endurance":5,
>>  "Element":"Fe"
>> }
>>
>> I would like to make a view that show all the docs that have some X
>> temperature, an endurance between Y and Z values and a W element. But the
>> ranged value could be any of the properties (or all properties)
>>
>> I thought If I make a map function that emit an array of this kind (
>> ["Temperature",23.4],["Endurance",5],["Element","Fe]]  )   for every
>> document I could filter it with startkey and endkey, but doesn't work as I
>> wish.
>>
>> Anyone knows how can I make a view that let me filter in that way?
>>
>> Thanks in advance
>>
>> Regards from Canary Islands
>>
>> Manuel Padron Martinez
>
>