Beispiel #1
0
            public RecursivePrefixTreeStrategyDistranceCustomScoreProvider(IndexReader reader, RecursivePrefixTreeStrategy strategy, PointPrefixTreeFieldCacheProvider cacheProvider, Point origin)
                : base(reader)
            {
                var ctx = strategy.GetSpatialContext();

                _originPt = origin;

                _calculator = ctx.GetDistCalc();
                _nullValue  = (ctx.IsGeo() ? 180 : float.MaxValue);
                _cache      = cacheProvider.GetCache(reader);
            }
Beispiel #2
0
        public static TopDocs DistanceFilter_RecursivePrefixTreeStrategy(Searcher searcher, RecursivePrefixTreeStrategy strategy, Point myLocation)
        {
            var ctx = strategy.GetSpatialContext();

            var q      = new MatchAllDocsQuery();
            var filter = strategy.MakeFilter(new SpatialArgs(SpatialOperation.Intersects,
                                                             ctx.MakeCircle(myLocation,
                                                                            DistanceUtils.Dist2Degrees(2000,
                                                                                                       DistanceUtils
                                                                                                       .EARTH_MEAN_RADIUS_KM))));

            // Reverse sorting...
            var sortField = new SortField(null, SortField.SCORE, true);

            TopDocs hits = searcher.Search(q, filter, 100, new Sort(sortField));

            return(hits);
        }