Package org.elasticsearch.client

Examples of org.elasticsearch.client.Client


            Proxy.getInvocationHandler(node);
            throw new Exception("Must not be proxyfied");
        } catch (IllegalArgumentException e) {
        }

        Client client = checkClient(true);
        client.admin().cluster().prepareState().execute().get();
    }
View Full Code Here


    protected Client checkClient(String name) {
        return checkClient(name, null);
    }

    protected Client checkClient(String name, Boolean async) {
        Client client;

        if (name != null) {
            client = ctx.getBean(name, Client.class);
        } else {
            client = ctx.getBean(Client.class);
View Full Code Here

        return xmlBeans;
    }
 
  @Test
  public void test_settings_are_not_updated() {
        Client client = checkClient("esClient");
        checkClient("esClient2");

        // We test how many shards and replica we have
        ClusterStateResponse response = client.admin().cluster().prepareState().execute().actionGet();
        assertThat(response.getState().getMetaData().getIndices().get("twitter").getNumberOfShards(), is(1));
        assertThat(response.getState().getMetaData().getIndices().get("twitter").getNumberOfReplicas(), is(0));
    }
View Full Code Here

        return xmlBeans;
    }

  @Test
  public void test_settings_without_mapping() {
    Client client = checkClient();

    // We should have an existing index here
        IndicesExistsResponse ier = client.admin().indices().prepareExists("twitter").execute().actionGet();
        assertThat(ier.isExists(), is(true));
    }
View Full Code Here

        return xmlBeans;
    }

  @Test
  public void test_transport_client_namespace() {
    Client client = checkClient("testTransportClient");
        assertThat(client, instanceOf(org.elasticsearch.client.transport.TransportClient.class));

    TransportClient tClient = (TransportClient) client;
    ImmutableList<TransportAddress> adresses = tClient.transportAddresses();
        assertThat("Nodes urls must not be empty...", adresses, not(emptyCollectionOf(TransportAddress.class)));
View Full Code Here

    @Test
    public void test_node_client() throws Exception {
        checkNode(true);

        Client client = checkClient(false);
        client.admin().cluster().prepareState().execute().get();
    }
View Full Code Here

    /**
     * External versions can start with 0 and also are able to get exported.
     */
    @Test
    public void testExternalVersion() {
        Client client = esSetup.client();
        deleteIndex("test");
        client.admin().indices().prepareCreate("test").execute().actionGet();
        client.admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet();

        client.prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(
                0).setVersionType(VersionType.EXTERNAL).execute().actionGet();
        client.admin().indices().prepareRefresh().execute().actionGet();

        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"_id\", \"_version\", \"_source\"]}");

        List<Map<String, Object>> infos = getExports(response);
View Full Code Here

    @Test
    public void testTimestampStored(){
        esSetup.execute(deleteAll(), createIndex("tsstored").withSettings(
                fromClassPath("essetup/settings/test_a.json")).withMapping("d",
                        "{\"d\": {\"_timestamp\": {\"enabled\": true, \"store\": \"yes\"}}}"));
        Client client = esSetup.client();
        client.prepareIndex("tsstored", "d", "1").setSource(
                "field1", "value1").setTimestamp("123").execute().actionGet();
        client.admin().indices().prepareRefresh().execute().actionGet();

        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"_id\", \"_timestamp\"]}");

        List<Map<String, Object>> infos = getExports(response);
View Full Code Here

    @Test
    public void testTTLEnabled() {
        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

    /**
     * The _routing field delivers the routing value if one is given.
     */
    @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

TOP

Related Classes of org.elasticsearch.client.Client

Copyright © 2018 www.massapicom. 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.