Java Code Examples for org.elasticsearch.action.update.UpdateResponse#toString()

The following examples show how to use org.elasticsearch.action.update.UpdateResponse#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticsearchHighRestFactory.java    From database-transform-tool with Apache License 2.0 6 votes vote down vote up
public String upsert(String index,String type,String id,Object json){
		try {
			if(xclient==null){
				init();
			}
//			IndexRequest indexRequest = new IndexRequest(index, type, id).source(json,XContentType.JSON);
//			UpdateRequest updateRequest = new UpdateRequest(index, type, id).doc(json,XContentType.JSON).upsert(indexRequest);
			UpdateRequest request = new UpdateRequest(index, type, id);
			request.upsert(JSON.parseObject(JSON.toJSONString(json)),XContentType.JSON);
			UpdateResponse response = xclient.update(request);
			return response.toString();
		}catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
 
Example 2
Source File: ElasticsearchHighRestFactory.java    From database-transform-tool with Apache License 2.0 5 votes vote down vote up
public String update(String index,String type,String id,Object json){
	try {
		if(xclient==null){
			init();
		}
		UpdateRequest request = new UpdateRequest(index, type, id);
		request.doc(JSON.parseObject(JSON.toJSONString(json)),XContentType.JSON);
		UpdateResponse response = xclient.update(request);
		return response.toString();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
Example 3
Source File: ElasticsearchTransportFactory.java    From database-transform-tool with Apache License 2.0 5 votes vote down vote up
public String update(String index,String type,String id,Object json){
	try {
		if(client==null){
			init();
		}
		UpdateResponse result = client.prepareUpdate(index, type, id).setDoc(JSON.parseObject(JSON.toJSONString(json)),XContentType.JSON).execute().actionGet();
		System.out.println(JSON.toJSONString(result));
		return result.toString();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
Example 4
Source File: ElasticsearchTransportFactory.java    From database-transform-tool with Apache License 2.0 5 votes vote down vote up
public String upsert(String index,String type,String id,Object json){
	try {
		if(client==null){
			init();
		}
		IndexRequest indexRequest = new IndexRequest(index, type, id).source(JSON.parseObject(JSON.toJSONString(json)),XContentType.JSON);
		UpdateRequest updateRequest = new UpdateRequest(index, type, id).doc(JSON.parseObject(JSON.toJSONString(json)),XContentType.JSON).upsert(indexRequest);              
		UpdateResponse result = client.update(updateRequest).get();
		return result.toString();
	}catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
Example 5
Source File: AdapterActionFutureActionGetMethodsInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
private void parseUpdateResponse(UpdateResponse updateResponse, AbstractSpan span) {
    if (TRACE_DSL) {
        String tagValue = updateResponse.toString();
        tagValue = ELASTICSEARCH_DSL_LENGTH_THRESHOLD > 0 ? StringUtil.cut(tagValue, ELASTICSEARCH_DSL_LENGTH_THRESHOLD) : tagValue;
        Tags.DB_STATEMENT.set(span, tagValue);
    }
}