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

📄 querylogging.java

📁 关于Ultraseek的一些用法,刚初学,所以都是比较简单
💻 JAVA
字号:
/* -*- mode:java; indent-tabs-mode:nil; c-basic-offset:2 -*- *  $RCSFile$ $Revision: 1.6 $ $Date: 2006/02/01 00:20:30 $ *  Copyright (c) 2004 Autonomy Corp.  All Rights Reserved. */import java.io.*;import java.util.*;import com.ultraseek.xpa.search.*;import com.ultraseek.xpa.server.*;/** * Logging queries. * <p> * This application demonstrates how to log queries to * the query log of an Ultraseek instance. * <p> * To use this application, edit the file "Sample.properties"  * to point to your Ultraseek server. *  * @see QueryLog * @see UltraseekServer#logQuery * @since XPA2.2 */public class QueryLogging {  /**   * Loads parameters from the file Sample.properties   */  static String getString(String key, String def) {    try {      String resourceName = System.getProperty("Sample");      if (resourceName==null) resourceName = "Sample";      ResourceBundle settings = ResourceBundle.getBundle( resourceName );      return settings.getString(key);    } catch (MissingResourceException e) {      return def;    } catch (Exception e) {      System.out.println( "Property file problem: "  + e );      return def;    }  }  static final String serverName  = getString("UltraseekServer.host",                                               "software-demo.ultraseek.com");  static final int    serverPort  = Integer.valueOf(getString("UltraseekServer.port",                                                               "80")).intValue();  static final String serverProto = getString("UltraseekServer.protocol",                                               "http");  static final String colName     = getString("UltraseekCollection.id", "loc");  static UltraseekServer server = new UltraseekServer(serverName, serverPort, serverProto);  static UltraseekCollection collection = null; // initialize later  /**   * Show the results of the query, and log it.   */  static void demoLogging(String query)    throws IOException {    Date queryStartTime = new Date();    System.out.println();    System.out.println("Query processing begins at " + queryStartTime);    Query q = Query.parse(query);    try {      SearchResultList srl = collection.search(q);      // Show summary of search results.      System.out.println();      System.out.println( "" + srl.getResultCount() + " document(s) match your query.");      if (!srl.isEmpty()) {        int nShowResults = Math.min(10, srl.size());        System.out.println();        System.out.println("Here are the URLs of results 1.." + nShowResults);        Iterator it = srl.iterator();        try {          for (int i = 0; i < nShowResults && it.hasNext(); i++) {            SearchResult searchResult = (SearchResult)it.next();            System.out.println(searchResult.getURL());          }        } catch (NoSuchElementException exc) {          /* No more results from server, not an error. */        }      }      server.logQuery(q, srl, collection.getID(), queryStartTime);      System.out.println();      System.out.println("Logged the query to " + server);    } catch (QueryNotSupportedException e) {      System.out.println( "Query problem: " + e );    }  }  static public void main(String args[])     throws IOException {    System.out.println("Query Logging Demo");    System.out.println("Using Ultraseek at " + server );    System.out.println(" (version " + server.getVersionString() +")" );    collection = (UltraseekCollection)server.getSearchCollection(colName);    if (collection == null) {      /* pick the first collection if the one in the property doesn't exist */      Iterator it = server.getSearchCollections().iterator();      if (it.hasNext()) {        collection = (UltraseekCollection)it.next();      } else {        System.out.println("No collections exist on " + server);        return;      }    }    System.out.println("Searching collection \"" + collection.getID() + "\"");    InputStreamReader inputStreamReader = new InputStreamReader(System.in);    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);    while (true) {      System.out.print("\n\nEnter a query (EOF to end): ");      String line = bufferedReader.readLine();      if (line==null) break;      try {        demoLogging( line );      } catch (IOException e) {        System.out.println( "Problem communicating with server: " + e );      } catch (XPARuntimeException e) {        System.out.println( "Problem communicating with server: " + e.getCause() );      }    }  }}

⌨️ 快捷键说明

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