You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mark Hahn <ma...@boutiquing.com> on 2011/04/01 07:00:32 UTC

Re: how to get documents by two or more keys?

I use a simple scheme for long/lat rectangular searching that is
working well, although not ideal.  I use emit(long, lat) and then I
query with startkey=long-ofs and endkey=long+ofs.  I don't use
include_docs so only the long and lat values come over the wire for
all results in that vertical "stripe".  Then I exclude the results
with out-of-range lat values giving me the doc ids.  A second batch
query gives me just the docs I want.

On Thu, Mar 31, 2011 at 8:19 AM, Nebu Pookins <ne...@gmail.com> wrote:
> On Tue, Mar 29, 2011 at 1:06 PM, Gabor Ratky
> <ga...@secretsaucepartners.com> wrote:
>> you can always come up with 'smart' complex keys where the data you need ends up together, one query away.
>
> What would the smart key be for this scenario?
>
> Your documents have represent entities on an infinite 2D field, and
> each document has an attribute representing their X and Y coordinates,
> among other things.
>
> You wish to find only the entities that are within the rectilinear
> rectangle defined by the top left corner (x1,y1) and bottom-right
> corner (x2,y2); or equivalently by its top-left corner and its width
> and height.
>
> I've been trying to think of a mapping of the points on a 2D plane to
> a 1D line, that would map the opposite corners of the rectangle as
> opposite endpoints of a line, but I haven't been able to find any such
> mapping that works for arbitrary coordinates of the rectangle.
>
> - Nebu
>



-- 
Mark Hahn
Website Manager
mark@boutiquing.com
949-229-1012