lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc <scattaman...@4info.com>
Subject Re: Lucene GeoNear Search and Sort Performance
Date Mon, 03 Jul 2017 15:18:16 GMT
While Indexing, I am  storing the following fields:

		doc.add(new StoredField("latitude", latitude));
		doc.add(new StoredField("longitude", longitude));
		doc.add(new LatLonPoint("loc", latitude, longitude));

As suggested, I added the following code:
		Query latlonQuery = LatLonPoint.newDistanceQuery("loc", minLat, minLng,
50);
		Sort s = new Sort(LatLonDocValuesField.newDistanceSort("loc", minLat,
minLng));
		TopDocs docs = searcher.search(latlonQuery, 50, s);

But it threw exception:

Exception in thread "main" java.lang.IllegalStateException: unexpected
docvalues type NONE for field 'loc' (expected one of [SORTED_NUMERIC,
NUMERIC]). Re-index with correct docvalues type.
	at org.apache.lucene.index.DocValues.checkField(DocValues.java:212)
	at org.apache.lucene.index.DocValues.getSortedNumeric(DocValues.java:284)
	at
org.apache.lucene.document.LatLonPointDistanceComparator.getLeafComparator(LatLonPointDistanceComparator.java:163)
	at
org.apache.lucene.search.FieldValueHitQueue.getComparators(FieldValueHitQueue.java:180)
	at
org.apache.lucene.search.TopFieldCollector$SimpleFieldCollector.getLeafCollector(TopFieldCollector.java:100)
	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:659)
	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:472)
	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:591)
	at
org.apache.lucene.search.IndexSearcher.searchAfter(IndexSearcher.java:576)
	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:503)

Question is should I also store LatLonDocValuesField while Indexing?

		doc.add(new LatLonDocValuesField("loc", latitude, longitude));






--
View this message in context: http://lucene.472066.n3.nabble.com/Lucene-GeoNear-Search-and-Sort-Performance-tp4343468p4343978.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message