couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darran White <>
Subject Re: Search for city by name, order by population
Date Wed, 14 Apr 2010 08:28:26 GMT
I've not tried it myself but maybe take a look at the couchdb lucene
It may help with your autocomplete search
Sent from my iPhone

On 13 Apr 2010, at 23:11, Jon Gretar Borgthorsson <
 > wrote:

> To be honest then in this exact case as you describe it I would skip
> sorting
> it in CouchDB and sort it on the client side. It's a very simple
> solution
> that can probably be done in a single line of code. I might even
> check and
> see if the autocomplete plugin you use simply offers to do that for
> you.
> When in doubt always do what has the least amount of code my great
> grandfather used to tell me. ;)
> On Mon, Apr 12, 2010 at 8:38 AM, Magnus Ottosson
> <>wrote:
>> 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
>> <> 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

View raw message