FileDocCategorySizeDatePackage
TermSearch.javaAPI DocExample2311Wed May 18 09:39:02 BST 2005com.discursive.jccook.xml.bardsearch

TermSearch

public final class TermSearch extends Object

Fields Summary
private static Logger
logger
Constructors Summary
private TermSearch()

Methods Summary
public static voidmain(java.lang.String[] pArgs)

      LogInit.init(); 
        logger.info("Searching for " + pArgs[0]);
        Searcher searcher = new IndexSearcher("index");
        Analyzer analyzer = new SimpleAnalyzer();
        Query query = QueryParser.parse(pArgs[0], "speech", analyzer);
        Hits hits = searcher.search(query);
        logger.info( "Searching Done, hit: " + hits.length() );

        System.out.println( "Score | Play | Act | Scene | Speaker" );
        
        for( int i = 0; i < hits.length(); i++ ) {
            Document doc = hits.doc(i);
            System.out.print( (int) (hits.score(i) * 100 ) );
            System.out.print( " | " + doc.get("play") + " | " + doc.get("act") );
            System.out.print( " | " + doc.get("scene") );
            System.out.print( " | " + doc.get("speaker") + "\n" );
        }