Package org.elasticsearch.client

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


        esSetup.execute(deleteAll(), createIndex("ttlenabled").withSettings(
                fromClassPath("essetup/settings/test_a.json")).withMapping("d",
                        "{\"d\": {\"_ttl\": {\"enabled\": true, \"default\": \"1d\"}}}"));
        Client client = esSetup.client();
        client.prepareIndex("ttlenabled", "d", "1").setSource("field1", "value1").execute().actionGet();
        client.admin().indices().prepareRefresh().execute().actionGet();

        Date now = new Date();
        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"_id\", \"_ttl\"]}");
        List<Map<String, Object>> infos = getExports(response);
View Full Code Here


     */
    @Test
    public void testRouting() {
        Client client = esSetup.client();
        client.prepareIndex("users", "d", "1").setSource("field1", "value1").setRouting("2").execute().actionGet();
        client.admin().indices().prepareRefresh().execute().actionGet();

        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"_id\", \"_source\", \"_routing\"]}");
        List<Map<String, Object>> infos = getExports(response);
        assertEquals("{\"_id\":\"2\",\"_source\":{\"name\":\"bike\"}}\n" +
View Full Code Here

            lValues[i] = i;
        }

        Random r = new Random();
        try {
            client.admin().indices().prepareCreate("test")
                    .setSettings(settingsBuilder().put(settings))
                    .addMapping("type1", jsonBuilder()
                        .startObject()
                            .startObject("type1")
                                .startObject("properties")
View Full Code Here

                if (((i * BATCH) % 10000) == 0) {
                    System.out.println("--> Indexed " + (i * BATCH) + " took " + stopWatch.stop().lastTaskTime());
                    stopWatch.start();
                }
            }
            client.admin().indices().prepareFlush("test").execute().actionGet();
            System.out.println("--> Indexing took " + stopWatch.totalTime() + ", TPS " + (((double) (COUNT)) / stopWatch.totalTime().secondsFrac()));
        } catch (Exception e) {
            System.out.println("--> Index already exists, ignoring indexing phase, waiting for green");
            ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10m").execute().actionGet();
            if (clusterHealthResponse.isTimedOut()) {
View Full Code Here

            }
            client.admin().indices().prepareFlush("test").execute().actionGet();
            System.out.println("--> Indexing took " + stopWatch.totalTime() + ", TPS " + (((double) (COUNT)) / stopWatch.totalTime().secondsFrac()));
        } catch (Exception e) {
            System.out.println("--> Index already exists, ignoring indexing phase, waiting for green");
            ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10m").execute().actionGet();
            if (clusterHealthResponse.isTimedOut()) {
                System.err.println("--> Timed out waiting for cluster health");
            }
        }
        if (client.prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount() != COUNT) {
View Full Code Here

                .settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();

        Client client = clientNode.client();

        try {
            client.admin().indices().create(createIndexRequest("index").settings(settings).mapping("type",
                    jsonBuilder().startObject().startObject("type").startObject("properties")
                        .startObject("low_card_str_value")
                            .field("type", "multi_field")
                            .startObject("fields")
                                .startObject("low_card_str_value")
View Full Code Here

                    System.out.println("--> Indexed " + i + " took " + stopWatch.stop().lastTaskTime());
                    stopWatch.start();
                }
            }

            client.admin().indices().prepareRefresh("index").execute().actionGet();
        } catch (Exception e) {
            System.out.println("Index already exists, skipping index creation");
        }

        ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10m").execute().actionGet();
View Full Code Here

            client.admin().indices().prepareRefresh("index").execute().actionGet();
        } catch (Exception e) {
            System.out.println("Index already exists, skipping index creation");
        }

        ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10m").execute().actionGet();
        if (clusterHealthResponse.isTimedOut()) {
            System.err.println("--> Timed out waiting for cluster health");
        }

        for (int i = 0; i < WARM + RUNS; ++i) {
View Full Code Here

                    .clusterName(clusterName)
                    .node();
        }
        Client client = nodes[0].client();

        client.admin().cluster().prepareHealth(indexName).setWaitForGreenStatus().setTimeout("10s").execute().actionGet();
        try {
            client.admin().indices().prepareCreate(indexName)
                    .addMapping(typeName, generateMapping("eager", "lazy"))
                    .get();
            Thread.sleep(5000);
View Full Code Here

        }
        Client client = nodes[0].client();

        client.admin().cluster().prepareHealth(indexName).setWaitForGreenStatus().setTimeout("10s").execute().actionGet();
        try {
            client.admin().indices().prepareCreate(indexName)
                    .addMapping(typeName, generateMapping("eager", "lazy"))
                    .get();
            Thread.sleep(5000);

            long startTime = System.currentTimeMillis();
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.