Package crate.elasticsearch.action.export

Examples of crate.elasticsearch.action.export.ExportResponse


        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);
        String stdout = infos.get(1).get("stdout").toString();
        assertTrue(stdout.startsWith("{\"_id\":\"1\",\"_ttl\":"));
        String lsplit  = stdout.substring(18);
View Full Code Here


    /**
     * The _index and _type fields can be fetched for every object.
     */
    @Test
    public void testIndexAndType() {
        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"_id\", \"_type\", \"_index\"]}");
        List<Map<String, Object>> infos = getExports(response);
        assertEquals("{\"_id\":\"2\",\"_type\":\"d\",\"_index\":\"users\"}\n" +
                "{\"_id\":\"4\",\"_type\":\"d\",\"_index\":\"users\"}\n",
                infos.get(1).get("stdout"));
View Full Code Here

    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" +
                "{\"_id\":\"4\",\"_source\":{\"name\":\"bus\"}}\n" +
                "{\"_id\":\"1\",\"_source\":{\"field1\":\"value1\"},\"_routing\":\"2\"}\n",
View Full Code Here

        esSetup2 = new EsSetup();
        esSetup2.execute(index("users", "d").withSource("{\"name\": \"motorbike\"}"));
        esSetup2.client().admin().cluster().prepareHealth().setWaitForGreenStatus().
            setWaitForNodes("2").setWaitForRelocatingShards(0).execute().actionGet();

        ExportResponse response = executeExportRequest(
                "{\"output_file\": \"export.${shard}.${index}.json\", \"fields\": [\"name\", \"_id\"], \"force_overwrite\": true}");

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

            restrictedFolder.delete();
        }
        restrictedFolder.mkdir();
        restrictedFolder.setWritable(false);

        ExportResponse response = executeExportRequest(
                "{\"output_file\": \"/tmp/testRestricted/export.json\", \"fields\": [\"_id\"]}");
        assertEquals(2, response.getFailedShards());
        assertTrue(response.getShardFailures()[0].reason().contains(
                "Insufficient permissions to write into /tmp/testRestricted"));
        restrictedFolder.delete();
    }
View Full Code Here

        new File(filename_0).delete();
        new File(filename_1).delete();
        new File(filename_0 += ".settings").delete();
        new File(filename_1 += ".settings").delete();

        ExportResponse response = executeExportRequest(
                "{\"output_file\": \"/tmp/${cluster}.${shard}.${index}.export\", \"fields\": [\"name\", \"_id\"], \"settings\": true}");

        List<Map<String, Object>> infos = getExports(response);
        assertEquals(2, infos.size());
        String settings_0 = new BufferedReader(new FileReader(new File(filename_0))).readLine();
View Full Code Here

    }

    @Test
    public void testSettingsFileExists() throws IOException {
        testSettings();
        ExportResponse response = executeExportRequest(
                "{\"output_file\": \"/tmp/${cluster}.${shard}.${index}.export\", \"fields\": [\"name\", \"_id\"], \"settings\": true}");
        List<Map<String, Object>> infos = getExports(response);
        assertEquals(0, infos.size());
        assertEquals(2, response.getShardFailures().length);
        assertTrue(response.getShardFailures()[0].reason().contains(
                "Export Failed [Failed to write settings for index users]]; nested: IOException[File exists"));
    }
View Full Code Here

                "Export Failed [Failed to write settings for index users]]; nested: IOException[File exists"));
    }

    @Test
    public void testSettingsWithOutputCmd() {
        ExportResponse response = executeExportRequest(
                "{\"output_cmd\": \"cat\", \"fields\": [\"name\", \"_id\"], \"settings\": true}");
        List<Map<String, Object>> infos = getExports(response);
        assertEquals(0, infos.size());
        assertTrue(response.getShardFailures()[0].reason().contains("Parse Failure [Parameter 'settings' requires usage of 'output_file']]"));
    }
View Full Code Here

        new File(filename_0).delete();
        new File(filename_1).delete();
        new File(filename_0 += ".mapping").delete();
        new File(filename_1 += ".mapping").delete();

        ExportResponse response = executeExportRequest(
                "{\"output_file\": \"/tmp/${cluster}.${shard}.${index}.export\", \"fields\": [\"name\", \"_id\"], \"mappings\": true}");

        List<Map<String, Object>> infos = getExports(response);
        assertEquals(2, infos.size());
        String mappings_0 = new BufferedReader(new FileReader(new File(filename_0))).readLine();
View Full Code Here

    }

    @Test
    public void testMappingsFileExists() throws IOException {
        testMappings();
        ExportResponse response = executeExportRequest(
                "{\"output_file\": \"/tmp/${cluster}.${shard}.${index}.export\", \"fields\": [\"name\", \"_id\"], \"mappings\": true}");
        List<Map<String, Object>> infos = getExports(response);
        assertEquals(0, infos.size());
        assertEquals(2, response.getShardFailures().length);
        assertTrue(response.getShardFailures()[0].reason().contains(
                "Export Failed [Failed to write mappings for index users]]; nested: IOException[File exists"));
    }
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.