incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hank Knight <hknight...@gmail.com>
Subject Re: CouchDB: Display 3 rows with the highest value
Date Tue, 30 Jul 2013 20:38:21 GMT
I need the top 50 results ordered by popularity, and I would prefer
not to have to rely on a third-party plugin like Lucene

My idea is to add a field to each document named "count":

{
    "_id": "1",
    "timestamp": 1375215867,
    "count": 0,
    "fruit": "gooseberry"
}

and then create an update function that would automatically add 1 to
the value of "count" for ALL documents where "fruit" has the value of
"gooseberry".  The problem with this idea is that millions of
documents could have to be updated every time a new document was
added.

Another idea would be to automatically create a temporary database
that swaps the position of the key and value every time a request for
the top 50 results is requested.  The problem with this idea is that
millions of documents would have to be put into a temporary table
every time this request was made.

Do either of these ideas sound like reasonable solutions that would
perform well under heavy loads?  Is Lucene the better solution?  Is
CouchDB a bad choice if I need the top 50 results ordered by
popularity?

Mime
View raw message