lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Currens (Updated) (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LUCENENET-462) Spatial Search skipping records with small radius e.g. 1 mile
Date Fri, 23 Mar 2012 18:15:29 GMT

     [ https://issues.apache.org/jira/browse/LUCENENET-462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Christopher Currens updated LUCENENET-462:
------------------------------------------

    Description: 
Running a spatial query against a list of locations all within 1 mile of a location returns
correct results for 2 miles, but incorrect results for 1 mile. For the one mile query, only
2 of the 8 rows are returned. 

Locations & Test below:
{code}

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

// Locations
AddPoint(writer, "Location 1", 51.5073802128877, -0.124669075012207);
AddPoint(writer, "Location 2", 51.5091, -0.1235);
AddPoint(writer, "Location 3", 51.5093, -0.1232);
AddPoint(writer, "Location 4", 51.5112531582845, -0.12509822845459);
AddPoint(writer, "Location 5", 51.5107, -0.123);
AddPoint(writer, "Location 6", 51.512, -0.1246);
AddPoint(writer, "Location 8", 51.5088760101322, -0.143165588378906);
AddPoint(writer, "Location 9", 51.5087958793819, -0.143508911132813);
{code}
{code}
[Test]
public void TestAntiM()
{
	_searcher = new IndexSearcher(_directory, true);

	const double miles = 1.0; // Bug? Only returns 2 locations. Should return 8. 
	// const double miles = 2.0; // Correct. Returns 8 Locations.

	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 8 " + distances.Count);
	Console.WriteLine("Results should be 8 " + results);

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



  was:
Running a spatial query against a list of locations all within 1 mile of a location returns
correct results for 2 miles, but incorrect results for 1 mile. For the one mile query, only
2 of the 8 rows are returned. 

Locations & Test below:

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

// Locations
AddPoint(writer, "Location 1", 51.5073802128877, -0.124669075012207);
AddPoint(writer, "Location 2", 51.5091, -0.1235);
AddPoint(writer, "Location 3", 51.5093, -0.1232);
AddPoint(writer, "Location 4", 51.5112531582845, -0.12509822845459);
AddPoint(writer, "Location 5", 51.5107, -0.123);
AddPoint(writer, "Location 6", 51.512, -0.1246);
AddPoint(writer, "Location 8", 51.5088760101322, -0.143165588378906);
AddPoint(writer, "Location 9", 51.5087958793819, -0.143508911132813);


		[Test]
		public void TestAntiM()
		{
			_searcher = new IndexSearcher(_directory, true);

			const double miles = 1.0; // Bug? Only returns 2 locations. Should return 8. 
			// const double miles = 2.0; // Correct. Returns 8 Locations.

			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 8 " + distances.Count);
			Console.WriteLine("Results should be 8 " + results);

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




    
> Spatial Search skipping records with small radius e.g. 1 mile
> -------------------------------------------------------------
>
>                 Key: LUCENENET-462
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-462
>             Project: Lucene.Net
>          Issue Type: Bug
>          Components: Lucene.Net Contrib
>    Affects Versions: Lucene.Net 2.9.4
>         Environment: .Net framework 4.0
>            Reporter: Mark Rodseth
>              Labels: lucene, spatialsearch
>
> Running a spatial query against a list of locations all within 1 mile of a location returns
correct results for 2 miles, but incorrect results for 1 mile. For the one mile query, only
2 of the 8 rows are returned. 
> Locations & Test below:
> {code}
> // Origin
> private double _lat = 51.508129;
> private double _lng = -0.128005;
> private const string LatField = "lat";
> private const string LngField = "lng";
> // Locations
> AddPoint(writer, "Location 1", 51.5073802128877, -0.124669075012207);
> AddPoint(writer, "Location 2", 51.5091, -0.1235);
> AddPoint(writer, "Location 3", 51.5093, -0.1232);
> AddPoint(writer, "Location 4", 51.5112531582845, -0.12509822845459);
> AddPoint(writer, "Location 5", 51.5107, -0.123);
> AddPoint(writer, "Location 6", 51.512, -0.1246);
> AddPoint(writer, "Location 8", 51.5088760101322, -0.143165588378906);
> AddPoint(writer, "Location 9", 51.5087958793819, -0.143508911132813);
> {code}
> {code}
> [Test]
> public void TestAntiM()
> {
> 	_searcher = new IndexSearcher(_directory, true);
> 	const double miles = 1.0; // Bug? Only returns 2 locations. Should return 8. 
> 	// const double miles = 2.0; // Correct. Returns 8 Locations.
> 	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 8 " + distances.Count);
> 	Console.WriteLine("Results should be 8 " + results);
> 	Assert.AreEqual(8, distances.Count); // fixed a store of only needed distances
> 	Assert.AreEqual(8, 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