couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex P <kol...@gmail.com>
Subject Re: CouchDB equivalent dynamic SQL
Date Fri, 30 Oct 2009 22:13:26 GMT
That will only work if you emit all the possible combinations of two  
items. Basically range query parameters have to have be the same form  
as the keys that you emit. If you want to do set operations on top of  
that, you either need lucene or do it manually on the client.

Sent from my iPhone

On Oct 30, 2009, at 3:46 PM, Duy Nguyen <duynguyen0511@yahoo.com> wrote:

> Thanks for reply , guys. If i want to select all tv or computer that  
> have price in between 1000 and 2000,
> ?startkey= [ ["computer", "tv"] , 1000]&endkey=[["computer", "tv"] ,  
> 2000]&include_docs=true
> Is it correct ?
>
> --- On Sat, 10/31/09, Adam Kocoloski <kocolosk@apache.org> wrote:
>
> From: Adam Kocoloski <kocolosk@apache.org>
> Subject: Re: CouchDB equivalent dynamic SQL
> To: user@couchdb.apache.org
> Date: Saturday, October 31, 2009, 12:59 AM
>
> On Oct 30, 2009, at 1:36 PM, Duy Nguyen wrote:
>
>> Hi guys,
>> I have a troublesome sql query that needs to translate to couchDB  
>> map/reduce
>> SELECT * FROM PRODUCTSWHERE [ PRICE ] AND [TYPE]'
>> Please note that Price and Type are dynamically generated depend on  
>> user inputs. ( i.e TYPEcan be 100 < PRICE < 1000, or 1 < PRICE <  
>> 100, or 1000 < PRICE < 10000. TYPE could be 'computer' , 'tv' etc..)
>> I can not do dynamically query on the fly with CouchDB. what is the  
>> best way to solve this problem ?
>
> Hi Duy, it won't always be a perfect translation.  But CouchDB's  
> compound view keys should be able to help you in this situation.  In  
> your map, emit([doc.type, doc.price], null) and then query the view  
> with
>
> ?startkey=["computer", 1000]&endkey=["computer", 10000] 
> &include_docs=true
>
> or
>
> ?startkey=["tv", 100]&endkey=["tv", 1000]&include_docs=true
>
> Best, Adam
>
>
>
>

Mime
View raw message