Last active
October 20, 2016 14:23
-
-
Save janakact/a2de8a4d3edc26e721228992eeef5b80 to your computer and use it in GitHub Desktop.
Initialize the index writer and index data.
This file contains hidden or 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(); | |
doc.add(new StoredField(NAME_TAG ,"Colombo Ratmalana")); //Stored fields will be stored in the index and values can be retrieved from the index | |
doc.add(new StoredField(CITY_TAG,"Colombo")); | |
//Index data as a LatLon Point | |
doc.add(new LatLonPoint(LOCATION_TAG, 6.821994,79.886208)); | |
//Index Altitude as a FloatPoint. An One-Dimensional Point | |
doc.add(new FloatPoint(ALT_TAG,22)); | |
//Write the document into Index | |
writer.addDocument(doc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment