1 | package org.xapian.examples;
|
---|
2 |
|
---|
3 | import org.xapian.WritableDatabase;
|
---|
4 | import org.xapian.XapianConstants;
|
---|
5 |
|
---|
6 | public class Delete1 {
|
---|
7 |
|
---|
8 | // Command line args - dbpath identifiers...
|
---|
9 | public static void main(String[] args)
|
---|
10 | {
|
---|
11 | if(args.length < 2)
|
---|
12 | {
|
---|
13 | System.out.println("Insufficient number of arguments (should be dbpath identifiers...)");
|
---|
14 | return;
|
---|
15 | }
|
---|
16 | deleteDocs(args[0], args);
|
---|
17 | }
|
---|
18 |
|
---|
19 | public static void deleteDocs(String dbpath, String[] identifierArgs)
|
---|
20 | {
|
---|
21 | // Open the database we're going to be deleting from.
|
---|
22 | WritableDatabase db = new WritableDatabase(dbpath, XapianConstants.DB_OPEN);
|
---|
23 |
|
---|
24 | //identifiers start from index 1
|
---|
25 | for(int i=1; i < identifierArgs.length; i++)
|
---|
26 | {
|
---|
27 | String idterm = "Q" + identifierArgs[i];
|
---|
28 | db.deleteDocument(idterm);
|
---|
29 | }
|
---|
30 |
|
---|
31 | // Commit to delete documents from disk
|
---|
32 | db.commit();
|
---|
33 | }
|
---|
34 | }
|
---|