Changeset 3101 for trunk/java-client/org
- Timestamp:
- 2002-04-25T12:44:10+12:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SimpleClient.java
r2220 r3101 56 56 import org.nzdl.gsdl.service.NzdlServiceClient; 57 57 import org.nzdl.gsdl.util.NzdlServiceFactory; 58 58 import org.nzdl.gsdl.service.NzdlFilterOption; 59 import org.nzdl.gsdl.service.NzdlFilterOptions; 59 60 /** 60 61 * Class SimpleClient … … 97 98 /** The query to use */ 98 99 String queryToQuery = "the"; 100 /** The index to use */ 101 String indexToQuery = ""; 99 102 /** Poll all collections */ 100 103 boolean examineAllCollections = false; … … 211 214 while (e.hasMoreElements()) { 212 215 String collName = (String) e.nextElement(); 213 NzdlCollectionInfo collInfo = nzdl.getCollectionInfo( collName ); 214 216 217 218 // get some basic col info - num docs in collection 219 NzdlCollectionInfo collInfo = nzdl.getCollectionInfo( collName ); 215 220 if (verbosity > 0) 216 221 System.out.println("Searching collection: " + collName); 217 222 218 long numResults = collInfo.getNumOfDocs(); // what precisely is this number ? 219 223 long numResults = collInfo.getNumOfDocs(); // number of docs in collection 220 224 if (verbosity > 2) 221 System.out.println("Collection " + collName + " suggests to get results in chunks of " + numResults + " hits" ); 222 if (verbosity > 2) 223 System.out.println("Query Term: " + queryTerm); 225 System.out.println("Collection " + collName + " has " + numResults + " documents" ); 226 227 // get some filter options for query filter - list the indexes available 228 NzdlFilterOptions filterops = nzdl.getFilterOptionSet(collName, "QueryFilter"); 229 230 NzdlFilterOption filt; 231 if (verbosity > 1) { 232 if (filterops.hasOption("Index")) { 233 filt = (NzdlFilterOption)filterops.getFilterOption("Index"); 234 System.out.println(collName+" has indexes "+ filt.validValues); 235 System.out.println("The default index is "+filt.defaultValue); 236 } 237 } 238 239 if (verbosity > 1) 240 System.out.print("Searching for query term: " + queryTerm+ ", in index: "); 241 if (indexToQuery=="") { 242 System.out.println("[default]"); 243 } 244 else { 245 System.out.println(indexToQuery); 246 } 224 247 String metaTag = "Title"; 225 248 226 if (verbosity > 2)227 249 // if (verbosity > 2) 250 //System.out.println("Searching in '" + metaTag + "' metadata"); 228 251 229 252 NzdlQuery query = new NzdlQuery( queryTerm ); 230 253 // return the first numResults that match 231 //query.setEndResults( 15);254 query.setEndResults( 200 ); 232 255 // "-1" means consider all the documents that match 233 query.setMaxDocs( -1 ); 256 query.setMaxDocs( 200); 257 query.setIndex(indexToQuery); // for mgpp colls, this must be a valid index, or "". otherwise it will cause an error. 234 258 235 259 NzdlRequest request = new NzdlRequest( query ); … … 286 310 s += "-a --all Examine all collections\n"; 287 311 s += "-q <query> --query <query> Use <query>\n"; 312 s += "-i <index> --index <index> Query the <index> index\n"; 288 313 s += "-d --docs Load the documents as well\n"; 289 314 s += "-Q --queryAllCollections Apply the <query> to all collections\n"; … … 301 326 System.err.println("in parseArgs"); 302 327 303 LongOpt[] longopts = new LongOpt[1 0];328 LongOpt[] longopts = new LongOpt[11]; 304 329 int i = 0; 305 330 StringBuffer sb = new StringBuffer(); … … 312 337 longopts[i++] = new LongOpt("all", LongOpt.NO_ARGUMENT, null, 'a'); 313 338 longopts[i++] = new LongOpt("query", LongOpt.REQUIRED_ARGUMENT, null, 'q'); 339 longopts[i++] = new LongOpt("index", LongOpt.REQUIRED_ARGUMENT, null, 'i'); 314 340 longopts[i++] = new LongOpt("docs", LongOpt.NO_ARGUMENT, null, 'd'); 315 341 longopts[i++] = new LongOpt("verbose", LongOpt.REQUIRED_ARGUMENT, null, 'v'); … … 317 343 Getopt g = new Getopt("org.nzdl.gsdl.SimpleClient", 318 344 args, 319 "hI:f:c:aq: dv:Qu:",345 "hI:f:c:aq:i:dv:Qu:", 320 346 longopts); 321 347 int c; … … 344 370 queryToQuery = g.getOptarg(); 345 371 break; 372 case 'i': 373 indexToQuery = g.getOptarg(); 374 break; 346 375 case 'a': 347 376 examineAllCollections = true; … … 381 410 client.pollCollections(); 382 411 383 client.runQuery();412 client.runQuery(); 384 413 385 414 } //main
Note:
See TracChangeset
for help on using the changeset viewer.