lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksandar Panov (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LUCENENET-483) Spatial Search skipping records when one location is close to origin, another is away and radius is wider
Date Mon, 09 Apr 2012 09:23:19 GMT
Spatial Search skipping records when one location is close to origin, another is away and radius
is wider
---------------------------------------------------------------------------------------------------------

                 Key: LUCENENET-483
                 URL: https://issues.apache.org/jira/browse/LUCENENET-483
             Project: Lucene.Net
          Issue Type: Bug
          Components: Lucene.Net Contrib
    Affects Versions: Lucene.Net 2.9.4g, Lucene.Net 2.9.4
         Environment: .Net framework 4.0
            Reporter: Aleksandar Panov


Running a spatial query against two locations where one location is close to origin (less
than a mile), another one is away (24 miles) and radius is wider (52 miles) returns only one
result. Running query with a bit wider radius (53.8) returns 2 results.

{code}

        // Origin
        private double _lat = 42.350153;
        private double _lng = -71.061667;
        private const string LatField = "lat";
        private const string LngField = "lng";

        //Locations            
        AddPoint(writer, "Location 1", 42.0, -71.0); //24 miles away from origin
        AddPoint(writer, "Location 2", 42.35, -71.06); //less than a mile

        [TestMethod]
        public void TestAntiM()
        {
            _directory = new RAMDirectory();

            var writer = new IndexWriter(_directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);

            SetUpPlotter(2, 15);

            AddData(writer);


            _searcher = new IndexSearcher(_directory, true);

            //const double miles = 53.8; // Correct. Returns 2 Locations.
            const double miles = 52; // Incorrect. Returns 1 Location.

            Console.WriteLine("testAntiM");
            // create a distance query
            var dq = new DistanceQueryBuilder(_lat, _lng, miles, LatField, LngField, CartesianTierPlotter.DefaltFieldPrefix,
true);

            Console.WriteLine(dq);
            //create a term query to search against all documents
            Query tq = new TermQuery(new Term("metafile", "doc"));

            var dsort = new DistanceFieldComparatorSource(dq.DistanceFilter);
            Sort sort = new Sort(new SortField("foo", dsort, false));

            // Perform the search, using the term query, the distance filter, and the
            // distance sort
            TopDocs hits = _searcher.Search(tq, dq.Filter, 1000, sort);
            int results = hits.TotalHits;
            ScoreDoc[] scoreDocs = hits.ScoreDocs;

            // Get a list of distances
            Dictionary<int, Double> distances = dq.DistanceFilter.Distances;

            Console.WriteLine("Distance Filter filtered: " + distances.Count);
            Console.WriteLine("Results: " + results);
            Console.WriteLine("=============================");
            Console.WriteLine("Distances should be 2 " + distances.Count);
            Console.WriteLine("Results should be 2 " + results);

            Assert.AreEqual(2, distances.Count); // fixed a store of only needed distances
            Assert.AreEqual(2, results);
        }

{code} 

--
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

        

Mime
View raw message