Dears,
I am a programer from China, and sorry for my poor English. Anyway, last week, when I used Solr to calculate 64-dimension manhattan disttance, I received a negative result, -20. As I know from wiki, "Manhattan distance is the sum of the absolute values of the horizontal and the vertical distance" In Java, it may be " int distance = Math.abs(x1-x0) + Math.abs(y1-y0); ", isn't it? but I am now confused with the source code of Spatial4j below: com.spatial4j.core.distance.DistanceUtils.vectorDistance(double[] vec1, double vec2, double power, double oneOverPower) if(power == 1.0){ for(int i=0; i<vec1.length;i++){ result += vec1[i] - vec2[i] } } NO MATH.ABS! Did I make a mistake? Pls reply me asap, thanks! Hope you have a nice day! William.Lee PS: a part of my Solr function query: fl=manhatton:dist(1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,0,1,0,1,0,1,1,1,0,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,0,0,0,1,0,1,1,0,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,0,1,0,0,1,0,0,1) |
Looks like you're right, William. I'm fixing the bug now. I'm kinda hopeful to get a Spatial4j version done within a month, and thus make it into Solr 4.6. Just curious; how does your application use this? I wouldn't know how to use it to any useful effect. I never added this distance function; it was inherited from a port from Lucene/Solr.
On Mon, Oct 28, 2013 at 11:56 PM, [hidden email] <[hidden email]> wrote: Dears, _______________________________________________ dev mailing list [hidden email] http://lists.spatial4j.com/listinfo.cgi/dev-spatial4j.com |
Thank you very much!
Hum... we just used mahattan distance to help us identify the neighborhood of each document. You know, a computed N-bit hash code can be seemed as an N-dimension vector. Then I found Solr function query could help me - the function dist() At last, I looked over the source code of Solr, and found a function in Spatial4j was called. Ha... Anyway, thanks for your reply again. Looking forward to the surprise Solr 4.6 would give. |
Free forum by Nabble | Edit this page |