1. 程式人生 > >Lucene 7.1如何利用RMI進行遠端搜尋

Lucene 7.1如何利用RMI進行遠端搜尋

package test.lucene.lucene1.remote;


import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import org.apache.lucene.queryparser.classic.ParseException;




public class SearchClient {
public static void main(String[] args) throws ParseException {
//在RMI服務登錄檔中查詢名稱為searcherFactory
的物件,並呼叫其上的方法
try {
SearcherFactory sf=(SearcherFactory) Naming.lookup("//localhost/searcherFactory");
sf.search("編輯");
} catch (MalformedURLException | RemoteException | NotBoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}


}