Oh, I should have made that more clear. I will use this to autocomplete a searchbox. So when the user start typing I will search for the cities that matches the string. The user might type "new". Then I want to fetch the 10 largest cities based on population where the name starts with "new".
If I just wanted to search for the name I could have created an index with the name as the key and searched like this: startkey="new"&endkey="new\u9999" and this would have matched all the cities with the name string with new. Right? I want to sort this result by population in descending order so I can fetch the 10 largest cities matching the input. Magnus On Mon, Apr 12, 2010 at 10:31 AM, Sebastian Cohnen <[email protected]> wrote: > hmm, I do not quite follow... isn't the name of the city unique? what do you > mean by *searching* for a city? > > On 12.04.2010, at 10:25, Magnus Ottosson wrote: > >> 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 > >
