List of usage examples for org.apache.lucene LucenePackage get
public static Package get()
From source file:com.browseengine.bobo.test.LucenePerf.java
License:Apache License
/** * @param args// w w w . j av a 2 s.com * @throws IOException * @throws CorruptIndexException * @throws InterruptedException * @throws BrowseException */ public static void main(String[] args) throws CorruptIndexException, IOException, InterruptedException, BrowseException { System.out.println(LucenePackage.get()); System.out.println(Arrays.toString(args)); String filename = "/Users/xgu/lucene29test/caches/people-search-index"; if (args.length > 0) filename = "/Users/xgu/lucene29test/caches/people-search-index"; System.out.println(filename); File file = new File(filename); FSDirectory directory = new SimpleFSDirectory(file); // FSDirectory directory = FSDirectory.getDirectory(file); System.out.println(directory.getClass().getName()); IndexReader reader = IndexReader.open(directory, true); loadFile(); // TermEnum termEnum = reader.terms(new Term("b", "")); // while(termEnum.next()) // { // Term t = termEnum.term(); // wordlist.add(t.text()); // } // words = wordlist.toArray(new String[1]); System.out.println("load the words " + words.length); final Collection<FacetHandler<?>> facetHandlers = new ArrayList<FacetHandler<?>>(); facetHandlers.add(new MultiValueFacetHandler("ccid", new PredefinedTermListFactory<Integer>(Integer.class, "0000000000"))); // facetHandlers.add(new MultiValueFacetHandler("pcid", new PredefinedTermListFactory<Integer>(Integer.class,"0000000000"))); facetHandlers.add(new SimpleFacetHandler("industry", new PredefinedTermListFactory<Integer>(Integer.class, "0000000000"))); facetHandlers.add(new SimpleFacetHandler("geo_region")); facetHandlers.add(new MultiValueFacetHandler("education_id", new PredefinedTermListFactory<Integer>(Integer.class, "0000000000"))); long tgetinstance = System.currentTimeMillis(); final BoboIndexReader boboReader = BoboIndexReader.getInstance(reader, facetHandlers, null); System.out.println("getInstanceTime: " + (System.currentTimeMillis() - tgetinstance)); //warming for (int x = 0; x < 30; x++) { doSearch(5, boboReader, facetHandlers); } long start = System.currentTimeMillis(); int numThread = 2; System.out.println(numThread + " threads"); int numItr = 1000; long ttime = 0; for (int x = 1; x < numItr + 1; x++) { long time = doSearch(numThread, boboReader, facetHandlers); ttime += time; if (x % 20 == 0) { System.out.println("total time: " + ttime); System.out.println( "average time: " + ((float) ttime / (float) x / (float) numThread / (float) inNumItr)); } } System.out.println("total time: " + ttime); System.out.println( "number of iterations: " + numItr + "\t\tnumThread: " + numThread + "\t\tinner itr: " + inNumItr); System.out.println( "average time: " + ((float) ttime / (float) numItr / (float) numThread / (float) inNumItr)); System.out.println(LucenePackage.get()); }
From source file:org.eu.bitzone.Leia.java
License:Apache License
public void actionAbout() { final Object about = addComponent(this, "/xml/about.xml", null, null); final Object lver = find(about, "lver"); setString(lver, "text", "Lucene version: " + LucenePackage.get().getImplementationVersion()); }
From source file:org.olat.search.service.indexer.OlatFullIndexer.java
License:Apache License
/** * @see java.lang.Runnable#run()// w w w .j av a 2s. com */ @Override public void run() { boolean runAgain = true; try { Thread.currentThread(); // TODO: Workround : does not start immediately Thread.sleep(10000); while (runAgain && !this.stopIndexing) { log.info( "full indexing starts... Lucene-version:" + LucenePackage.get().getImplementationVersion()); fullIndexerStatus.indexingStarted(); doIndex(); index.indexingIsDone(); fullIndexerStatus.indexingFinished(); log.info("full indexing done in " + fullIndexerStatus.getIndexingTime() + "ms"); // OLAT-5630 - dump more infos about the indexer run - for analysis later final FullIndexerStatus status = getStatus(); log.info("full indexing summary: started: " + status.getFullIndexStartedAt()); log.info("full indexing summary: counter: " + status.getDocumentCount()); log.info("full indexing summary: index.per.minute: " + status.getIndexPerMinute()); log.info("full indexing summary: finished: " + status.getLastFullIndexTime()); log.info("full indexing summary: time: " + status.getIndexingTime() + " ms"); log.info("full indexing summary: size: " + status.getIndexSize()); log.info("full indexing summary: document counters: " + status.getDocumentCounters()); log.info("full indexing summary: file type counters:" + status.getFileTypeCounters()); log.info("full indexing summary: excluded counter: " + status.getExcludedDocumentCount()); if (restartInterval == 0) { log.debug("do not run again"); runAgain = false; } else { if (log.isDebug()) { log.debug("Indexing sleep=" + restartInterval + "ms"); } fullIndexerStatus.setStatus(FullIndexerStatus.STATUS_SLEEPING); Thread.sleep(restartInterval); if (log.isDebug()) { log.debug("Restart indexing"); } } } } catch (final InterruptedException iex) { log.info("FullIndexer was interrupted ;" + iex.getMessage()); } catch (final Throwable ex) { try { log.error("Error during full-indexing:" + ex.getMessage(), ex); } catch (final NullPointerException nex) { // no logging available (shut down) => do nothing } } fullIndexerStatus.setStatus(FullIndexerStatus.STATUS_STOPPED); stopIndexing = true; try { log.info("quit indexing run."); } catch (final NullPointerException nex) { // no logging available (shut down)=> do nothing } }