Package org.elasticsearch.action.get

Examples of org.elasticsearch.action.get.GetResponse.source()


        logger.info("Get [type1/1] with script");
        for (int i = 0; i < 5; i++) {
            getResult = client1.prepareGet("test", "type1", "1").setFields("_source.type1.name").execute().actionGet();
            assertThat(getResult.index(), equalTo(getConcreteIndexName()));
            assertThat(getResult.exists(), equalTo(true));
            assertThat(getResult.source(), nullValue());
            assertThat(getResult.field("_source.type1.name").values().get(0).toString(), equalTo("test"));
        }

        logger.info("Get [type1/2] (should be empty)");
        for (int i = 0; i < 5; i++) {
View Full Code Here


        assertThat(response.sourceAsMap().get("field2").toString(), equalTo("value2"));

        logger.info("--> realtime get 1 (no source)");
        response = client.prepareGet("test", "type1", "1").setFields(Strings.EMPTY_ARRAY).execute().actionGet();
        assertThat(response.exists(), equalTo(true));
        assertThat(response.source(), nullValue());

        logger.info("--> realtime get 1 (no type)");
        response = client.prepareGet("test", null, "1").execute().actionGet();
        assertThat(response.exists(), equalTo(true));
        assertThat(response.sourceAsMap().get("field1").toString(), equalTo("value1"));
View Full Code Here

        assertThat(response.exists(), equalTo(false));

        logger.info("--> realtime fetch of field (requires fetching parsing source)");
        response = client.prepareGet("test", "type1", "1").setFields("field1").execute().actionGet();
        assertThat(response.exists(), equalTo(true));
        assertThat(response.source(), nullValue());
        assertThat(response.field("field1").values().get(0).toString(), equalTo("value1"));
        assertThat(response.field("field2"), nullValue());

        logger.info("--> flush the index, so we load it from it");
        client.admin().indices().prepareFlush().execute().actionGet();
View Full Code Here

        assertThat(response.sourceAsMap().get("field2").toString(), equalTo("value2"));

        logger.info("--> realtime fetch of field (loaded from index)");
        response = client.prepareGet("test", "type1", "1").setFields("field1").execute().actionGet();
        assertThat(response.exists(), equalTo(true));
        assertThat(response.source(), nullValue());
        assertThat(response.field("field1").values().get(0).toString(), equalTo("value1"));
        assertThat(response.field("field2"), nullValue());

        logger.info("--> update doc 1");
        client.prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").execute().actionGet();
View Full Code Here

        client.admin().indices().prepareRefresh().execute().actionGet();

        for (int i = 1; i < 100; i++) {
            GetResponse getResponse = client.prepareGet("test", "type1", Integer.toString(i)).execute().actionGet();
            assertThat(getResponse.source(), equalTo(buildSource(i).copiedBytes()));
        }
        GetResponse getResponse = client.prepareGet("test", "type1", Integer.toString(10000)).execute().actionGet();
        assertThat(getResponse.source(), equalTo(buildSource(10000).copiedBytes()));

        for (int i = 1; i < 100; i++) {
View Full Code Here

        for (int i = 1; i < 100; i++) {
            GetResponse getResponse = client.prepareGet("test", "type1", Integer.toString(i)).execute().actionGet();
            assertThat(getResponse.source(), equalTo(buildSource(i).copiedBytes()));
        }
        GetResponse getResponse = client.prepareGet("test", "type1", Integer.toString(10000)).execute().actionGet();
        assertThat(getResponse.source(), equalTo(buildSource(10000).copiedBytes()));

        for (int i = 1; i < 100; i++) {
            SearchResponse searchResponse = client.prepareSearch().setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(i))).execute().actionGet();
            assertThat(searchResponse.hits().getTotalHits(), equalTo(1l));
            assertThat(searchResponse.hits().getAt(0).source(), equalTo(buildSource(i).copiedBytes()));
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.