Skip to content

Instantly share code, notes, and snippets.

@catap
Created December 12, 2018 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catap/010d07edb04c2bc7ab7c01ba0accc46a to your computer and use it in GitHub Desktop.
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.
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