couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Gable <>
Subject Re: View advice
Date Fri, 08 Apr 2011 03:21:39 GMT
This, in my opinion, is a compelling reason to add unions (in the math  
sense). Take one query and merge the results with the results of  
another query on the same map function (and thus reduce). This is kind  
of like multiple startkeys and endkeys.

I'd do the two queries you'd write and union with #3 and merge the  
results in your app. In Ruby, results = result1 + result2. If this is  
a CouchApp, you might have to use a list function or something (idk  
what this is).

On Apr 7, 2011, at 10:13 PM, Pierre-Alexandre Lacerte <

 > wrote:

> I am currently trying to create a view to reproduce this SQL query:
> SELECT * FROM articles WHERE articles.location="NY" OR  
> articles.location="CA" ORDER BY articles.release_date DESC
> I tried to create a view with a complex key: function(doc) { if 
> (doc.type == "Article") { emit([doc.location, doc.release_date],  
> doc) } }
> And then using startkey and endkey to retrieve one location and  
> ordering the result on the release date.
> "NY", {}]&endkey=["NY"]&limit=5&descending=true
> This works fine.
> However, I learned that I cannot send multiple startkeys and endkeys  
> to my view. (To mimic WHERE articles.location="NY" OR  
> articles.location="CA")
> How should I design this? (It could happen that I would need to  
> query for 15 different locations)
> So far, I have 3 suggestions:
> 1- Store the view output in its own database, and make a new view to  
> sort by release date. I'm not sure if this option will be fast and  
> scale well...
> 2- Use couchdb-lucene.
> 3- Hack my version to support multiple startkeys or endkeys.
> Thanks for your help,
> Pierre

View raw message