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

📄 searchonecollection.java

📁 关于Ultraseek的一些用法,刚初学,所以都是比较简单
💻 JAVA
字号:
/* -*- mode:java; indent-tabs-mode:nil; c-basic-offset:2 -*- * *  $RCSFile$ $Revision: 1.21 $ $Date: 2006/01/25 16:56:21 $ * *  Copyright (c) 2000-2002 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.BufferedReader;import java.io.InputStreamReader;import java.util.Collection;import java.util.Iterator;import java.util.NoSuchElementException;import com.ultraseek.xpa.search.Query;import com.ultraseek.xpa.search.SearchCollection;import com.ultraseek.xpa.search.SearchResult;import com.ultraseek.xpa.search.SearchResultList;import com.ultraseek.xpa.search.SearchServer;import com.ultraseek.xpa.search.SearchTopic;import com.ultraseek.xpa.server.UltraseekServer;/** *  A simple demo application that searches  *  an Ultraseek collection. */public class SearchOneCollection {  SearchOneCollection() { }  public static void main(String[] args) throws Exception {    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("an Ultraseek collection.");    System.out.println();    System.out.println("Enter the hostname and TCP port of your");    System.out.println("running Ultraseek instance.");    System.out.print("hostname: ");    String host = bufferedReader.readLine();    System.out.print("TCP port: ");    int port = Integer.parseInt(bufferedReader.readLine());    SearchServer searchServer = new UltraseekServer(host,port);    System.out.println();    System.out.println("Here is the SearchServer object:");    System.out.println(searchServer);    System.out.println();    System.out.println("Enter the internal name of the collection.");    System.out.print("collection: ");    String id = bufferedReader.readLine();    SearchCollection searchCollection = searchServer.getSearchCollection(id);    System.out.println();    System.out.println("Here is the SearchCollection object:");    System.out.println(searchCollection);    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);      System.out.println();      System.out.println("Here is the Query object:");      System.out.println(query);      SearchResultList searchResultList = searchCollection.search(query);      System.out.println();      System.out.println("Here is the SearchResultList object:");      System.out.println(searchResultList);      Collection relatedTopics = searchResultList.getRelatedTopics();      System.out.println();      if (!relatedTopics.isEmpty()) {        System.out.println("Here are the SearchTopic objects:");        Iterator iterator = relatedTopics.iterator();        while (iterator.hasNext()) {          SearchTopic searchTopic = (SearchTopic)iterator.next();          System.out.println(searchTopic);        }      } else {        System.out.println("There are no SearchTopic objects.");      }      System.out.println();      if (!searchResultList.isEmpty()) {        System.out.println("Here are the SearchResult objects:");        Iterator iterator = searchResultList.iterator();        try {          while (iterator.hasNext()) {            SearchResult searchResult = (SearchResult)iterator.next();            System.out.println();            System.out.println(searchResult);          }        } catch (NoSuchElementException e) {          /* No more results from server, not an error. */        }      } else {        System.out.println("There are no SearchResult objects.");      }    }  }}

⌨️ 快捷键说明

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