는 지금까지 내가 아는 한, Elasticsearch는 인제 스트 파이프 라인을 정의하기위한 자바 API가 없습니다. 주변의 일, 당신은 HttpURLConnection의 사용 JAVA에서 인제 스트 파이프 라인을 정의하기 위해 다음을 수행 할 수 있습니다으로 :
URL obj = new URL("http://localhost:9200/_ingest/pipeline/timestamp");
String json = "{\n" +
" \"description\": \"describe pipeline\",\n" +
" \"processors\": [\n" +
" {\n" +
" \"set\": {\n" +
" \"field\": \"timestamp\",\n" +
" \"value\": \"{{_ingest.timestamp}}\"\n" +
" }\n" +
" }\n" +
" ]\n" +
"}";
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("PUT");
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
osw.write(json);
osw.flush();
osw.close();
System.out.println(con.getResponseCode() + " : " + con.getResponseMessage());
if (con != null)
con.disconnect();
을 그리고 지금, 아래 만들어진 "타임 스탬프"를 통해 전달하여 인덱싱 문서의 자바 코드 파이프 라인을 인제 스트 :
를
TransportClient client = buildTransPortClient();
Map<String, Object> object = new HashMap<String, Object>();
object.put("user","kimchy");
object.put("postDate",new Date());
object.put("message","trying out Elasticsearch");
IndexResponse response = client.prepareIndex("test", "test", "100")
.setSource(object)
.setPipeline("timestamp")
.get();
System.out.println(response);
내 이해에 따라, 당신은 이미 Ingest 파이프 라인 "타임 스탬프"를 정의했습니다. 이제는 매번 "timestamp"파이프 라인을 통해 전달하여 색인 문서에 JAVA API 만 필요합니다. 권리? –
답장을 보내 주셔서 감사합니다! 좀 빠지는. 우리는 그 코드 전체를 java로 번역하고 싶습니다. 파이프 라인의 정의를 포함합니다. – Tameem
하지만 왜 파이프 라인 정의를 매번 정의해야합니까? 데이터 삽입 또는 조작 전에 한 번 정의해야하는 일종의 메타 정보 또는 매핑입니다. –