| 1 |
|
package org.apache.lucene.demo; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
import org.apache.lucene.store.Directory; |
| 20 |
|
import org.apache.lucene.store.FSDirectory; |
| 21 |
|
import org.apache.lucene.index.IndexReader; |
| 22 |
|
import org.apache.lucene.index.Term; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
| 27 |
|
public class DeleteFiles { |
| 28 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 29 |
0
|
private DeleteFiles() {} ... |
| 30 |
|
|
| 31 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.23 |
|
| 32 |
0
|
public static void main(String[] args) {... |
| 33 |
0
|
String usage = "java org.apache.lucene.demo.DeleteFiles <unique_term>"; |
| 34 |
0
|
if (args.length == 0) { |
| 35 |
0
|
System.err.println("Usage: " + usage); |
| 36 |
0
|
System.exit(1); |
| 37 |
|
} |
| 38 |
0
|
try { |
| 39 |
0
|
Directory directory = FSDirectory.getDirectory("index", false); |
| 40 |
0
|
IndexReader reader = IndexReader.open(directory); |
| 41 |
|
|
| 42 |
0
|
Term term = new Term("path", args[0]); |
| 43 |
0
|
int deleted = reader.deleteDocuments(term); |
| 44 |
|
|
| 45 |
0
|
System.out.println("deleted " + deleted + |
| 46 |
|
" documents containing " + term); |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
0
|
reader.close(); |
| 56 |
0
|
directory.close(); |
| 57 |
|
|
| 58 |
|
} catch (Exception e) { |
| 59 |
0
|
System.out.println(" caught a " + e.getClass() + |
| 60 |
|
"\n with message: " + e.getMessage()); |
| 61 |
|
} |
| 62 |
|
} |
| 63 |
|
} |