elasticsearch jest client 주의사항
public void indexSampleArticles() {
Article article1 = new Article();
article1.setId(10L);
article1.setAuthor("Robert Anthony Salvatore2222222222222");
article1.setContent("Homeland follows the story of Drizzt from around the time and circumstances of his birth and his upbringing amongst the drow (dark elves). " +
"The book takes the reader into Menzoberranzan, the drow home city. From here, the reader follows Drizzt on his quest to follow his principles in a land where such " +
"feelings are threatened by all his family including his mother Matron Malice. In an essence, the book introduces Drizzt Do'Urden," +
" one of Salvatore's more famous characters from the Icewind Dale Trilogy.");
Article article2 = new Article();
article2.setId(3L);
article2.setAuthor("John Ronald Reuel Tolkien");
article2.setContent("The Lord of the Rings is an epic high fantasy novel written by English philologist and University of Oxford professor J. R. R. Tolkien. " +
"The story began as a sequel to Tolkien's 1937 children's fantasy novel The Hobbit, but eventually developed into a much larger work. " +
"It was written in stages between 1937 and 1949, much of it during World War II.[1] It is the third best-selling novel ever written, with over 150 million copies sold");
try {
// Delete articles index if it is exists
//DeleteIndex deleteIndex = new DeleteIndex.Builder("articles").build();
//jestClient.execute(deleteIndex);
IndicesExists indicesExists = new IndicesExists.Builder("articles").build();
JestResult result = jestClient.execute(indicesExists);
if (!result.isSucceeded()) {
// Create articles index
CreateIndex createIndex = new CreateIndex.Builder("articles").build();
jestClient.execute(createIndex);
}
/**
* if you don't want to use bulk api use below code in a loop.
*
* Index index = new Index.Builder(source).index("articles").type("article").build();
* jestClient.execute(index);
*
*/
Bulk bulk = new Bulk.Builder()
.addAction(new Index.Builder(article1).index("articles").type("article").build())
.addAction(new Index.Builder(article2).index("articles").type("article").build())
.build();
result = jestClient.execute(bulk);
System.out.println(result.getJsonString());
} catch (IOException e) {
logger.error("Indexing error", e);
} catch (Exception e) {
logger.error("Indexing error", e);
}
}
id 삽입을 반복할 때 업데이트 작업을 합니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.