Skip to content

Instantly share code, notes, and snippets.

View SearchData.java
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
@janakact
janakact / IndexData.java
Last active Oct 20, 2016
Initialize the index writer and index data.
View IndexData.java
// --------------------------------------------------------------------------------
//Initiate the writer -------------------------------------------------------------
writer = new IndexWriter(indexDir, new IndexWriterConfig(
new WhitespaceAnalyzer()).setOpenMode(IndexWriterConfig.OpenMode.CREATE));
//Index Data ----------------------------------------------------------------------
//Sample Data 1 -------------------------------------------------------------------
Document doc = new Document();
View pom.xml
<!-- 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>