Package crate.elasticsearch.action.export

Examples of crate.elasticsearch.action.export.ExportResponse


     * The 'force_overwrite' parameter forces existing files to be overwritten.
     */
    @Test
    public void testForceOverwrite() {
        String filename = "/tmp/filename.export";
        ExportResponse response = executeExportRequest("{\"output_file\": \"" + filename +
                "\", \"fields\": [\"name\"], \"force_overwrite\": \"true\"}");

        List<Map<String, Object>> infos = getExports(response);
        assertEquals(2, infos.size());
        assertEquals("/tmp/filename.export", infos.get(0).get("output_file").toString());
View Full Code Here


     * response therefore does not contain the stderr, stdout and exitcode
     * values.
     */
    @Test
    public void testExplainCommand() {
        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"name\"], \"explain\": \"true\"}");

        List<Map<String, Object>> infos = getExports(response);
        assertEquals(2, infos.size());
        Map<String, Object> shard_info = infos.get(0);
View Full Code Here

        // Do export request
        String source = "{\"output_cmd\": \"cat\", \"fields\": [\"name\"]}";
        ExportRequest exportRequest = new ExportRequest();
        exportRequest.source(source);
        ExportResponse response = esSetup2.client().execute(
                ExportAction.INSTANCE, exportRequest).actionGet();

        // The two shard results are from different nodes and have no failures
        assertEquals(0, response.getFailedShards());
        List<Map<String, Object>> infos = getExports(response);
        assertNotSame(infos.get(0).get("node_id"), infos.get(1).get("node_id"));
    }
View Full Code Here

    /**
     * A query must also work and deliver only the queried results.
     */
    @Test
    public void testWithQuery() {
        ExportResponse response = executeExportRequest(
                "{\"output_file\": \"/tmp/query-${shard}.json\", \"fields\": [\"name\"], " +
                "\"query\": {\"match\": {\"name\":\"bus\"}}, \"force_overwrite\": true}");

        assertEquals(0, response.getFailedShards());
        List<Map<String, Object>> infos = getExports(response);
        assertEquals(2, infos.size());

        List<String> lines_0 = readLines("/tmp/query-0.json");
        assertEquals(0, lines_0.size());
View Full Code Here

                setWaitForGreenStatus().execute().actionGet().getClusterName();
        String filename_0 = "/tmp/" + clusterName + ".0.users.nocompressexport.gz";
        String filename_1 = "/tmp/" + clusterName + ".1.users.nocompressexport.gz";
        new File(filename_0).delete();
        new File(filename_1).delete();
        ExportResponse response = executeExportRequest(
                "{\"output_file\": \"/tmp/${cluster}.${shard}.${index}.lzivexport.gz\", \"fields\": [\"name\", \"_id\"], \"compression\": \"LZIV\"}");

        assertEquals(2, response.getFailedShards());
        assertTrue(response.getShardFailures()[0].reason().contains(
                "Compression format 'lziv' unknown or not supported."));

        ExportResponse response2 = executeExportRequest(
                "{\"output_file\": \"/tmp/${cluster}.${shard}.${index}.nocompressexport.gz\", \"fields\": [\"name\", \"_id\"], \"compression\": \"\"}");

        assertEquals(0, response2.getFailedShards());
        assertEquals(2, response2.getSuccessfulShards());
    }
View Full Code Here

     * The field _version returns the correct version.
     */
    @Test
    public void testVersion() {
        esSetup.execute(index("users", "d", "2").withSource("{\"name\": \"electric bike\"}"));
        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"_id\", \"_version\", \"_source\"]}");

        List<Map<String, Object>> infos = getExports(response);
        assertEquals(2, infos.size());
        assertShardInfoCommand(infos.get(1), "users", 0,
View Full Code Here

        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);
        assertEquals(3, infos.size());
        assertEquals(
View Full Code Here

    /**
     * The _timestamp field is not returned if the mapping does not store the timestamps.
     */
    @Test
    public void testTimestampNotStored() {
        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"_id\", \"_timestamp\"]}");
        List<Map<String, Object>> infos = getExports(response);
        assertEquals("{\"_id\":\"1\"}\n{\"_id\":\"3\"}\n", infos.get(0).get("stdout"));
    }
View Full Code Here

        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);
        assertEquals("{\"_id\":\"1\",\"_timestamp\":123}\n", infos.get(1).get("stdout"));
    }
View Full Code Here

    /**
     * If _ttl is not enabled in the mapping, the _ttl field is not in the output.
     */
    public void testTTLNotEnabled() {
        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"_id\", \"_ttl\"]}");
        List<Map<String, Object>> infos = getExports(response);
        assertEquals("{\"_id\":\"1\"}\n{\"_id\":\"3\"}\n", infos.get(0).get("stdout"));
    }
View Full Code Here

TOP

Related Classes of crate.elasticsearch.action.export.ExportResponse

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.