problem with two key ranges in couchdb
Posted
by Duasto
on Stack Overflow
See other posts from Stack Overflow
or by Duasto
Published on 2010-01-02T13:28:38Z
Indexed on
2010/04/18
9:53 UTC
Read the original article
Hit count: 235
I'm having problem getting the right results in my coordinate system. To explain my system, I have this simple database that have x_axis, y_axis and name columns. I don't need to get all the data, I just need to display some part of it.
For example, I have a coordinate system that have 10:10(meaning from x_axis -10 to 10 and from y_axis -10 to 10) and I want to display only 49 coordinates. In sql query I can do it something like this: "select * from coordinate where x_axis >= -3 and x_axis <= 3 and y_axis >= -3 y_axis <= 3"
I tried this function but no success:
"by_range": {
"map": "function(doc) { emit([doc.x_axis, doc.y_axis], doc) }"
}
by_range?startkey=[-3,-3]&endkey=[3,3]
I got a wrong results of:
-3x-3 -3x-2 -3x-1 -3x0 -3x1 -3x2 -3x3 <-- should not display this part --> -3x4 -3x5 -3x6 -3x7 -3x8 -3x9 -3x10 <-- end of should not display this part --> ..... up to 3x3
to give you a better understanding of my project here is the screenshot of that I want to be made: Oops they don't allowed new poster to post an image img96(dot)imageshack(dot)us/img96/5382/coordinates(dot)jpg <<< just change the "(dot)" to "."
© Stack Overflow or respective owner