GeoHashFilteredDocIdSet does not work at all
--------------------------------------------

                 Key: LUCENENET-448
                 URL: https://issues.apache.org/jira/browse/LUCENENET-448
             Project: Lucene.Net
          Issue Type: Bug
          Components: Lucene.Net Contrib
    Affects Versions: Lucene.Net 2.9.4
         Environment: Windows 7 x64
            Reporter: Jeff Johnson
             Fix For: Lucene.Net 2.9.4


The GeoHashFilteredDocIdSet is assuming the values are always in the cache 
which is wrong. A proposed fix for the method is listed here for 
GeoHashDistanceFilter.cs:

public GeoHashFilteredDocIdSet(DocIdSet innerSet, string[] geoHashValues, 
Dictionary<string, double> distanceLookupCache, double lat, double lng, int 
docBase, double distance, Dictionary<int, double> distances) 
                : base(innerSet , (docid) => /* was: public override Match */
                        {
                                String geoHash = geoHashValues[docid];
                                double[] coords = GeoHashUtils.Decode(geoHash);
                                double x = coords[0];
                                double y = coords[1];

                                double cachedDistance;
                distanceLookupCache.TryGetValue(geoHash, out cachedDistance);
                                double d;

                                if (cachedDistance > 0)
                                {
                                        d = cachedDistance;
                                }
                                else
                                {
                                        d = 
DistanceUtils.GetInstance().GetDistanceMi(lat, lng, x, y);
                                        distanceLookupCache[geoHash] = d;
                                }

                                if (d < distance)
                                {
                                        distances[docid + docBase] = d;
                                        return true;
                                }
                                
                                return false;
                        })
                        {
                                _geoHashValues = geoHashValues;
                                _distances = distances;
                                _distance = distance;
                                _docBase = docBase;
                                _lng = lng;
                                _lat = lat;
                                _distanceLookupCache = distanceLookupCache;
                        }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to