You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Prescott Nasser (JIRA)" <ji...@apache.org> on 2012/05/30 17:41:23 UTC
[jira] [Resolved] (LUCENENET-483) Spatial Search skipping records
when one location is close to origin, another one is away and radius is
wider
[ https://issues.apache.org/jira/browse/LUCENENET-483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Prescott Nasser resolved LUCENENET-483.
---------------------------------------
Resolution: Fixed
Resolved per comments
> Spatial Search skipping records when one location is close to origin, another one 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.4, Lucene.Net 2.9.4g
> Environment: .Net framework 4.0
> Reporter: Aleksandar Panov
> Assignee: Itamar Syn-Hershko
> Labels: lucene, spatialsearch
> Fix For: Lucene.Net 3.0.3
>
>
> 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.
> IMPORTANT UPDATE: Problem can't be reproduced in Java, with using original Lucene.Spatial (2.9.4 version) library.
> {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