Examples of prepareIndex()


Examples of com.dotcms.repackage.org.elasticsearch.client.Client.prepareIndex()

    public void putToIndex(String idx, String json, String id){
     try{
       Client client=new ESClient().getClient();

       IndexResponse response = client.prepareIndex(idx, SiteSearchAPI.ES_SITE_SEARCH_MAPPING, id)
              .setSource(json)
              .execute()
              .actionGet();

    } catch (Exception e) {
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

        final AtomicBoolean stop = new AtomicBoolean();

        Thread indexingThread = new Thread() {
            @Override public void run() {
                while (!stop.get()) {
                    client.prepareIndex("test", "type1").setSource("field", System.currentTimeMillis()).execute().actionGet();
                }
            }
        };
        indexingThread.start();
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

        int COUNT = 200000;
        System.out.println("Indexing [" + COUNT + "] ...");
        int i = 1;
        for (; i <= COUNT; i++) {
//            client1.admin().cluster().preparePingSingle("test", "type1", Integer.toString(i)).execute().actionGet();
            client1.prepareIndex("test", "type1").setId(Integer.toString(i)).setSource(source(Integer.toString(i), "test" + i))
                    .setCreate(false).execute().actionGet();
            if ((i % 10000) == 0) {
                System.out.println("Indexed " + i + " took " + stopWatch.stop().lastTaskTime());
                stopWatch.start();
            }
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

        }

        System.out.println("---> START Indexing initial data [" + NUMBER_OF_DOCS + "]");
        final Client client = nodes[0].client();
        for (int i = 0; i < NUMBER_OF_DOCS; i++) {
            client.prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value").execute().actionGet();
        }
        System.out.println("---> DONE Indexing initial data [" + NUMBER_OF_DOCS + "]");

        final AtomicBoolean done = new AtomicBoolean();
        // start indexer
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

        final AtomicBoolean done = new AtomicBoolean();
        // start indexer
        Thread indexer = new Thread(new Runnable() {
            @Override public void run() {
                while (!done.get()) {
                    client.prepareIndex("test", "type", Integer.toString(ThreadLocalRandom.current().nextInt(NUMBER_OF_DOCS)))
                            .setSource("field", "value").execute().actionGet();
                }
            }
        });
        indexer.start();
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

            for (int doc = 0; doc < NUM_DOCS; doc++) {
                if (!flushed && doc > FLUSH_AFTER) {
                    flushed = true;
                    client.admin().indices().prepareFlush(indexName).execute().actionGet();
                }
                client.prepareIndex(indexName, "type1", Integer.toString(doc)).setSource("field", "value" + doc).execute().actionGet();
            }
            System.out.println("--> DONE index [" + indexName + "]");
        }

        System.out.println("--> Initiating shutdown");
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

            client.admin().indices().prepareCreate("index_" + i)
                    .setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", numberOfShards).put("index.number_of_replicas", numberOfReplicas))
                    .execute().actionGet();

            for (int j = 0; j < numberOfDocs; j++) {
                client.prepareIndex("index_" + i, "type").setSource("field1", "test", "field2", 2, "field3", new Date()).execute().actionGet();
            }
            logger.info("DONE  index [{}]", i);
        }

        client.admin().indices().prepareGatewaySnapshot().execute().actionGet();
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

            client = NodeBuilder.nodeBuilder().client(true).node().client();
        } else {
            client = node.client();
        }

        client.prepareIndex("test", "type1", "1").setSource("field1", "value1").execute().actionGet();

        StopWatch stopWatch = new StopWatch().start();
        for (long i = 0; i < OPERATIONS; i++) {
            client.prepareGet("test", "type1", "1").execute().actionGet();
        }
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

        int COUNT = 200000;
        int QUERIES = 10;
        // register queries
        for (int i = 0; i < QUERIES; i++) {
            client1.prepareIndex("_percolator", "test", Integer.toString(i))
                    .setSource(jsonBuilder().startObject()
                            .field("query", termQuery("name", "value"))
                            .endObject())
                    .setRefresh(true)
                    .execute().actionGet();
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

        Client client = client("node1");
        client.admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("index.number_of_shards", 1)).execute().actionGet();

        logger.info("--> register a query");
        client.prepareIndex("_percolator", "test", "kuku")
                .setSource(jsonBuilder().startObject()
                        .field("color", "blue")
                        .field("query", termQuery("field1", "value1"))
                        .endObject())
                .setRefresh(true)
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.