Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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.
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
You can’t perform that action at this time.