[ https://issues.apache.org/jira/browse/LUCENENET-483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280257#comment-13280257 ]
Aleksandar Panov commented on LUCENENET-483: -------------------------------------------- I apologize Itamar it was my fault with source code due to lack of knowledge with GitHub web interface. I had been downloading source with download button instead with zip button. After I successfully download source code I still wasn't able to clarify my test since there is an error in the source code. https://github.com/synhershko/lucene.net/blob/spatial2trunk/src/core/Util/AttributeSource.cs Line 249 always throws an exception (attClass is of type TermAttribute). Even if I run your tests from Lucene.Net.Contrib.Spatial.Test.Various (for instance test method RadiusOf15Something) I still get that error. It might be I had been doing something wrong. > 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 > 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