incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre-Alexandre Lacerte <pierrealexandre.lace...@gmail.com>
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
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.

http://myhost.com:8000/mydb/_design/application/_view/articles?startkey=["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. https://issues.apache.org/jira/browse/COUCHDB-523

Thanks for your help,

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