Examples of sourceAsMap()


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

        logger.info("--> realtime get 1");
        response = client.prepareGet("test", "type1", "1").execute().actionGet();
        assertThat(response.exists(), equalTo(true));
        assertThat(response.sourceAsMap().get("field1").toString(), equalTo("value1_1"));
        assertThat(response.sourceAsMap().get("field2").toString(), equalTo("value2_1"));

        logger.info("--> update doc 1 again");
        client.prepareIndex("test", "type1", "1").setSource("field1", "value1_2", "field2", "value2_2").execute().actionGet();

        response = client.prepareGet("test", "type1", "1").execute().actionGet();
View Full Code Here

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

        logger.info("--> update doc 1 again");
        client.prepareIndex("test", "type1", "1").setSource("field1", "value1_2", "field2", "value2_2").execute().actionGet();

        response = client.prepareGet("test", "type1", "1").execute().actionGet();
        assertThat(response.exists(), equalTo(true));
        assertThat(response.sourceAsMap().get("field1").toString(), equalTo("value1_2"));
        assertThat(response.sourceAsMap().get("field2").toString(), equalTo("value2_2"));

        DeleteResponse deleteResponse = client.prepareDelete("test", "type1", "1").execute().actionGet();
        assertThat(deleteResponse.notFound(), equalTo(false));
View Full Code Here

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

        client.prepareIndex("test", "type1", "1").setSource("field1", "value1_2", "field2", "value2_2").execute().actionGet();

        response = client.prepareGet("test", "type1", "1").execute().actionGet();
        assertThat(response.exists(), equalTo(true));
        assertThat(response.sourceAsMap().get("field1").toString(), equalTo("value1_2"));
        assertThat(response.sourceAsMap().get("field2").toString(), equalTo("value2_2"));

        DeleteResponse deleteResponse = client.prepareDelete("test", "type1", "1").execute().actionGet();
        assertThat(deleteResponse.notFound(), equalTo(false));

        response = client.prepareGet("test", "type1", "1").execute().actionGet();
View Full Code Here

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

        client.prepareIndex("test", "type", "1").setSource("field", fieldValue).execute().actionGet();

        // realtime get
        GetResponse getResponse = client.prepareGet("test", "type", "1").execute().actionGet();
        assertThat(getResponse.exists(), equalTo(true));
        assertThat(getResponse.sourceAsMap().get("field").toString(), equalTo(fieldValue));
    }
}
View Full Code Here

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

                        // no river, we need to add it to the routing with no node allocation
                        try {
                            client.admin().indices().prepareRefresh(riverIndexName).execute().actionGet();
                            GetResponse getResponse = client.prepareGet(riverIndexName, mappingType, "_meta").execute().actionGet();
                            if (getResponse.exists()) {
                                String riverType = XContentMapValues.nodeStringValue(getResponse.sourceAsMap().get("type"), null);
                                if (riverType == null) {
                                    logger.warn("no river type provided for [{}], ignoring...", riverIndexName);
                                } else {
                                    routingBuilder.put(new RiverRouting(new RiverName(riverType, mappingType), null));
                                    dirty = true;
View Full Code Here

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

                String lastSeq = null;
                try {
                    client.admin().indices().prepareRefresh(riverIndexName).execute().actionGet();
                    GetResponse lastSeqGetResponse = client.prepareGet(riverIndexName, riverName().name(), "_seq").execute().actionGet();
                    if (lastSeqGetResponse.exists()) {
                        Map<String, Object> couchdbState = (Map<String, Object>) lastSeqGetResponse.sourceAsMap().get("couchdb");
                        if (couchdbState != null) {
                            lastSeq = couchdbState.get("last_seq").toString();
                        }
                    }
                } catch (Exception e) {
View Full Code Here

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

        try {
            name = name.toLowerCase();
            GetRequestBuilder grb = client.prepareGet(getIndexName(), getIndexType(), name);           
            GetResponse gr = grb.execute().actionGet();
            if (gr.isExists())
                return readDoc(gr.id(), gr.version(), gr.sourceAsMap());           
        } catch (Exception ex) {
            logger.error("Couldn't load user with screenName:" + name + " " + ex.getMessage());           
        }
        return null;
    }
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest.sourceAsMap()

            Long ttl = null;
            IndexRequest indexRequest = request.docAsUpsert() ? request.doc() : request.upsertRequest();
            if (request.scriptedUpsert() && (request.script() != null)) {
                // Run the script to perform the create logic
                IndexRequest upsert = request.upsertRequest();              
                Map<String, Object> upsertDoc = upsert.sourceAsMap();
                Map<String, Object> ctx = new HashMap<>(2);
                // Tell the script that this is a create and not an update
                ctx.put("op", "create");
                ctx.put("_source", upsertDoc);
                try {
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest.sourceAsMap()

                routing = indexRequest.routing();
            }
            if (indexRequest.parent() != null) {
                parent = indexRequest.parent();
            }
            boolean noop = !XContentHelper.update(updatedSourceAsMap, indexRequest.sourceAsMap(), request.detectNoop());
            // noop could still be true even if detectNoop isn't because update detects empty maps as noops.  BUT we can only
            // actually turn the update into a noop if detectNoop is true to preserve backwards compatibility and to handle
            // cases where users repopulating multi-fields or adding synonyms, etc.
            if (request.detectNoop() && noop) {
                operation = "none";
View Full Code Here

Examples of org.elasticsearch.cluster.metadata.MappingMetaData.sourceAsMap()

        if (viewContext == null) {
            // Then, get the view stored in the mapping _meta field
            MappingMetaData mappingMetaData = clusterService.state().metaData().index(request.index()).mapping(request.type());
            if (mappingMetaData != null) {
                try {
                    Map<String, Object> mapping = mappingMetaData.sourceAsMap();
                    viewContext = extract(mapping, request.format());
                } catch (IOException e) {
                    throw new ElasticSearchParseException("Failed to parse mapping content to map", e);
                }
            }
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.