⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchmirroringservers.java

📁 关于Ultraseek的一些用法,刚初学,所以都是比较简单
💻 JAVA
字号:
/* -*- mode:java; indent-tabs-mode:nil; c-basic-offset:2 -*- * *  $RCSFile$ $Revision: 1.22 $ $Date: 2006/01/25 16:56:21 $ * *  Copyright (c) 2000-2004 Autonomy Corp.  All Rights Reserved. *  Permission to use, copy, modify, and distribute this file is hereby *  granted without fee, provided that the above copyright notice appear *  in all copies. */import java.io.*;import java.util.*;import com.ultraseek.xpa.search.*;import com.ultraseek.xpa.server.*;/** *  A simple demo application that searches  *  two running Ultraseek instances. */public class SearchMirroringServers {  SearchMirroringServers() { }  public static void main(String[] args) throws Exception {    boolean VERBOSE = false;    // Set to true for more output    InputStreamReader inputStreamReader = new InputStreamReader(System.in);    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);    System.out.println();    System.out.println("This is a simple demo application that searches");    System.out.println("two mirroring Ultraseek instances.");    System.out.println();    System.out.println("Specify your first running Ultraseek instance:");    System.out.print("hostname: ");    String host1 = bufferedReader.readLine();    System.out.print("TCP port: ");    int port1 = Integer.parseInt(bufferedReader.readLine());    UltraseekServer searchServer1 = new UltraseekServer(host1,port1);    System.out.println( searchServer1.toString() + " " + searchServer1.getVersionString() );    System.out.println();    System.out.println("Specify your second running Ultraseek instance.");    System.out.print("hostname: ");    String host2 = bufferedReader.readLine();    System.out.print("TCP port: ");    int port2 = Integer.parseInt(bufferedReader.readLine());    UltraseekServer searchServer2 = new UltraseekServer(host2,port2);    System.out.println( searchServer2.toString() + " " + searchServer2.getVersionString() );    SearchServer group =       new MirrorGroup(new SearchServer[]{searchServer1,searchServer2});    if (VERBOSE) {      System.out.println();      System.out.println("Here is the MirrorGroup object:");      System.out.println(group);    }    System.out.println();    Collection collections = group.getSearchCollections();    if (collections.size() == 0) {      System.out.println( "The servers have no search collections in common." );      System.out.println( "Collections searched with a MirrorGroup must have the same internal name.");    } else {      System.out.println( "There are " + collections.size() + " search collections common to the servers." );      Iterator i = collections.iterator();      System.out.println( "    ID  \tLocale\tSearch\tShow\tName" );      while (i.hasNext()) {        SearchCollection c = (SearchCollection) i.next();        System.out.println( " " + c.getID() + "   \t" + c.getLocale() +                             "\t" + c.getDefaultSearch() + "\t" + c.getDefaultShow() +                            "\t" + c.getName() );      }    }    for (;;) {      System.out.println();      System.out.println("Enter a query.");      System.out.print("search: ");      String line = bufferedReader.readLine();      if (line==null) break;      Query query = Query.parse(line);      if (VERBOSE) {        System.out.println();        System.out.println("Here is the Query object:");        System.out.println(query);      }      long start_time = System.currentTimeMillis();      long end_time;      SearchResultList searchResultList = group.search(query);      if (VERBOSE) {        System.out.println();        System.out.println("Here is the SearchResultList object:");        System.out.println(searchResultList);      }      System.out.println();      if (!searchResultList.isEmpty()) {        SearchResult searchResult = (SearchResult) searchResultList.get(0);        end_time = System.currentTimeMillis();        if (searchResult.getSearchServer() == searchServer1)          System.out.println( "Server One was used for this search (" + searchServer1 + ")" );        else if (searchResult.getSearchServer() == searchServer2)          System.out.println( "Server Two was used for this search (" + searchServer2 + ")" );        else          System.out.println( "The server used for this search was: " + searchResult.getSearchServer() );        System.out.println( "There are about " + searchResultList.getResultCount() + " results." );      } else {        // Without a SearchResult we have no way of determining which server was used.        end_time = System.currentTimeMillis();        System.out.println("There are no results.");      }      System.out.println( "Search took " + (end_time - start_time) + "ms" );    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -