This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core --> | |
<dependency> | |
<groupId>org.apache.lucene</groupId> | |
<artifactId>lucene-core</artifactId> | |
<version>6.1.0</version> | |
<!--<version>3.6.2</version>--> | |
</dependency> | |
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-facet --> | |
<dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -------------------------------------------------------------------------------- | |
//Initiate the writer ------------------------------------------------------------- | |
writer = new IndexWriter(indexDir, new IndexWriterConfig( | |
new WhitespaceAnalyzer()).setOpenMode(IndexWriterConfig.OpenMode.CREATE)); | |
//Index Data ---------------------------------------------------------------------- | |
//Sample Data 1 ------------------------------------------------------------------- | |
Document doc = new Document(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
searcher = new IndexSearcher(DirectoryReader.open(writer)); | |
// DPoints within 30 km from colombo city | |
TopDocs docs = searcher.search(LatLonPoint.newDistanceQuery(LOCATION_TAG, COLOMBO_LAT,COLOMBO_LON, 30000), 5); | |
System.out.println("Within 30km"); | |
printRecords(docs); | |
// DPoints within 20 km from colombo city |