Add --enable-deletion option to buildindex. If used, buildindex will remove deleted...
[beagle.git] / beagled / Lucene.Net / Search / RemoteSearchable.cs
blobb9ae14f6116caa96d39b8fb1c0f01f84a551572f
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 using System;
17 using Document = Lucene.Net.Documents.Document;
18 using Term = Lucene.Net.Index.Term;
19 namespace Lucene.Net.Search
22 /// <summary>A remote searchable implementation. </summary>
23 [Serializable]
24 public class RemoteSearchable : System.MarshalByRefObject, Lucene.Net.Search.Searchable
27 private Lucene.Net.Search.Searchable local;
29 /// <summary>Constructs and exports a remote searcher. </summary>
30 public RemoteSearchable(Lucene.Net.Search.Searchable local) : base()
32 this.local = local;
35 public virtual void Search(Query query, Filter filter, HitCollector results)
37 local.Search(query, filter, results);
40 public virtual void Search(Weight weight, Filter filter, HitCollector results)
42 local.Search(weight, filter, results);
45 public virtual void Close()
47 local.Close();
50 public virtual int DocFreq(Term term)
52 return local.DocFreq(term);
56 public virtual int[] DocFreqs(Term[] terms)
58 return local.DocFreqs(terms);
61 public virtual int MaxDoc()
63 return local.MaxDoc();
66 public virtual TopDocs Search(Query query, Filter filter, int n)
68 return local.Search(query, filter, n);
71 public virtual TopDocs Search(Weight weight, Filter filter, int n)
73 return local.Search(weight, filter, n);
76 public virtual TopFieldDocs Search(Query query, Filter filter, int n, Sort sort)
78 return local.Search(query, filter, n, sort);
81 public virtual TopFieldDocs Search(Weight weight, Filter filter, int n, Sort sort)
83 return local.Search(weight, filter, n, sort);
86 public virtual Document Doc(int i)
88 return local.Doc(i);
91 public virtual Query Rewrite(Query original)
93 return local.Rewrite(original);
96 public virtual Explanation Explain(Query query, int doc)
98 return local.Explain(query, doc);
101 public virtual Explanation Explain(Weight weight, int doc)
103 return local.Explain(weight, doc);
106 /// <summary>Exports a searcher for the index in args[0] named
107 /// "//localhost/Searchable".
108 /// </summary>
109 [STAThread]
110 public static void Main(System.String[] args)
112 System.Runtime.Remoting.RemotingConfiguration.Configure("Lucene.Net.Search.RemoteSearchable.config");
113 System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Http.HttpChannel(1099));
114 // create and install a security manager
115 if (false) //{{}}// if (System.getSecurityManager() == null) // {{Aroush-1.4.3}} >> 'java.lang.System.getSecurityManager()'
117 //{{}}// System.setSecurityManager(new RMISecurityManager()); // {{Aroush-1.4.3}} >> 'java.lang.System.setSecurityManager()' and 'java.rmi.RMISecurityManager.RMISecurityManager()'
120 Lucene.Net.Search.Searchable local = new IndexSearcher(args[0]);
121 RemoteSearchable impl = new RemoteSearchable(local);
123 // bind the implementation to "Searchable"
124 System.Runtime.Remoting.RemotingServices.Marshal(impl, "tcp://localhost:1099/Searchable");
125 System.Console.ReadLine();