Tokenize 001234 as 1234. Include a testing function in NoiseFilter to figure out...
[beagle.git] / beagled / MasterDelete.cs
blob89b7a2c8f4d4c27e20794c069e71a91b7513666c
1 //
2 // MasterDelete.cs
3 //
4 // Copyright (C) 2005 Novell, Inc.
5 //
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
28 using System;
29 using System.Collections;
30 using System.IO;
32 using Beagle.Util;
33 using Beagle.Daemon;
35 class MasterDeleteTool {
37 static void Main (string[] args)
39 string index_dir = args [0];
40 Uri uri_to_delete = new Uri (args [1], false);
42 if (! Directory.Exists (index_dir)) {
43 Console.WriteLine ("No such directory: {0}", index_dir);
44 return;
47 LuceneDriver driver = new LuceneDriver (index_dir);
49 ICollection hits = driver.DoQueryByUri (uri_to_delete);
51 if (hits == null || hits.Count == 0) {
52 Console.WriteLine ("Uri {0} not found in the index in {1}",
53 uri_to_delete, index_dir);
54 return;
57 driver.Remove (uri_to_delete);
58 driver.Flush ();
60 Console.WriteLine ("Uri {0} deleted", uri_to_delete);