If you use [name, population] as the key I believe you'll get what you need.
You could query the view like this: ?startkey=["name"]&endkey=["name",{}]
Also check out the article on view collation on the wiki:
http://wiki.apache.org/couchdb/View_collation
Nils Breunese.
________________________________________
Van: Magnus Ottosson [[email protected]]
Verzonden: maandag 12 april 2010 10:25
Aan: [email protected]
Onderwerp: Search for city by name, order by population
Hi,
I have a database with the names and population of cities (about 7
million entities). Is it possible, with couchdb, to create a key that
includes both cityname and population where I can search for a name
and get the matching results ordered by the population?
I tried to create a key like [population, name] and search like this
?startkey=[0, "name"]&endkey=[10000000, "name]&limit=10 but it does
not work like the way I hoped.
Any ideas?
Magnus
De informatie vervat in deze e-mail en meegezonden bijlagen is uitsluitend
bedoeld voor gebruik door de geadresseerde en kan vertrouwelijke informatie
bevatten. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking
van deze informatie aan derden is voorbehouden aan geadresseerde. De VPRO staat
niet in voor de juiste en volledige overbrenging van de inhoud van een
verzonden e-mail, noch voor tijdige ontvangst daarvan.