couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre-Alexandre Lacerte <>
Subject View advice
Date Fri, 08 Apr 2011 03:13:59 GMT
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

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,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message