incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <>
Subject Re: Views with parameters
Date Wed, 15 Jul 2009 22:05:14 GMT
Well, that depends on what you're attempting with numbers.

For the record, if you index numeric values then sorting already works
correctly. That is if you called doc.add(1) and doc.add(10), the order
would be correct when you sorted. What won't be correct is a range
query (q=[1 TO 10]) as that's text-based. You can also fix that if you
padded the numbers out with zeros. But *that* fails for negative
values, so to handle that you have to invert negative values around
some chosen "most negative number" and prepend it with a - (or
anything that's lexicographically lower than a 0). Lucene's
NumberTools is the usual solution around this but it's ugly.

couchdb-lucene could make numeric handling easier than it does but you
can get quite far today. My other project uses Lucene extensively and
provides correct sorting and querying on numeric ranges. I cannot
reuse that work here as its proprietary, so I've been putting it off.
Frankly, I was waiting for Lucene 3.0 (probably 3.1) where there's a
possibility of big improvements around numeric handling in general.

Anyone that wants to help out before then can contact my via github or
on #couchdb.


On Wed, Jul 15, 2009 at 10:54 PM, Barry Wark<> wrote:
> On Wed, Jul 15, 2009 at 10:10 AM, Paul Davis<> wrote:
>> On Wed, Jul 15, 2009 at 12:26 PM, Manuel de la
>> Pena<> wrote:
>>> Hello,
>>> I have started looking a couchDb for a project of mine. I fully
>>> understand the idea of documents and the work wot be performed with
>>> them. But I have some question about the views: is there a way to pass
>>> parameter to the views? So far all I have read points that views are
>>> that, views and that I need to know them before hand. How do I make a
>>> query at runtime then?
>>> Is passing parameter in the view url work?
>> There are two answers to this quite common question:
>> 1. You're Doing It Wrong in so much that query a view needs to be
>> thought of differently than something like an SQL query. Lots of
>> people find that the types of questions they want to answer are in
>> fact answerable using the view system.
>> 2. Your questions truly are dynamic and you need dynamic query
>> capabilities so you should use something like couchdb-lucene.
> Keep in mind that couchdb-lucene is awesome for full-text queries but
> doesn't (yet) support numeric queries.
>> I can't say much else without more specifics.
>> HTH,
>> Paul Davis
>>> Kr,
>>> Manuel

View raw message