Created
December 12, 2018 08:03
-
-
Save catap/010d07edb04c2bc7ab7c01ba0accc46a to your computer and use it in GitHub Desktop.
Very simple and naive tools to force recreate Lucene index. It may be used when your elastic data is corrupted, you have only one shard and Lucen's CheckIndex doesn't help.
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
mport org.apache.lucene.index.IndexWriter; | |
import org.apache.lucene.index.IndexWriterConfig; | |
import org.apache.lucene.store.Directory; | |
import org.apache.lucene.store.SimpleFSDirectory; | |
import java.io.IOException; | |
import java.nio.file.Paths; | |
public class IndexFixer { | |
public static void main(String[] args) throws IOException { | |
if (args.length != 1) { | |
System.out.println("You should specified a path to index to fix"); | |
return; | |
} | |
Directory d = new SimpleFSDirectory(Paths.get(args[0])); | |
IndexWriterConfig conf = new IndexWriterConfig(); | |
IndexWriter writer = new IndexWriter(d, conf); | |
writer.commit(); | |
writer.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment