Examples of PercolatorExecutor


Examples of org.elasticsearch.index.percolator.PercolatorExecutor

                        bind(PercolatorExecutor.class).asEagerSingleton();
                    }
                }
        ).createInjector();

        final PercolatorExecutor percolatorExecutor = injector.getInstance(PercolatorExecutor.class);

        XContentBuilder doc = XContentFactory.jsonBuilder().startObject().startObject("doc")
                .field("field1", 1)
                .field("field2", "value")
                .field("field3", "the quick brown fox jumped over the lazy dog")
                .endObject().endObject();
        final byte[] source = doc.copiedBytes();

        PercolatorExecutor.Response percolate = percolatorExecutor.percolate(new PercolatorExecutor.SourceRequest("type1", source));

        for (int i = 0; i < NUMBER_OF_QUERIES; i++) {
            percolatorExecutor.addQuery("test" + i, termQuery("field3", "quick"));
        }


        System.out.println("Warming Up (1000)");
        StopWatch stopWatch = new StopWatch().start();
        System.out.println("Running " + 1000);
        for (long i = 0; i < 1000; i++) {
            percolate = percolatorExecutor.percolate(new PercolatorExecutor.SourceRequest("type1", source));
        }
        System.out.println("[Warmup] Percolated in " + stopWatch.stop().totalTime() + " TP Millis " + (NUMBER_OF_ITERATIONS / stopWatch.totalTime().millisFrac()));

        System.out.println("Percolating using " + NUMBER_OF_THREADS + " threads with " + NUMBER_OF_ITERATIONS + " iterations, and " + NUMBER_OF_QUERIES + " queries");
        final CountDownLatch latch = new CountDownLatch(NUMBER_OF_THREADS);
        Thread[] threads = new Thread[NUMBER_OF_THREADS];
        for (int i = 0; i < threads.length; i++) {
            threads[i] = new Thread(new Runnable() {
                @Override public void run() {
                    for (long i = 0; i < NUMBER_OF_ITERATIONS; i++) {
                        PercolatorExecutor.Response percolate = percolatorExecutor.percolate(new PercolatorExecutor.SourceRequest("type1", source));
                    }
                    latch.countDown();
                }
            });
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.