ES增刪改查

2021-10-09 06:19:51 字數 1360 閱讀 9232

@autowired

private resthighlevelclient resthighlevelclient;

//建立索引

@test

public void testcreateindex() throws ioexception

//獲取索引

@test

public void testexistindex() throws ioexception

//新增文件

@test

public void testcreatedocument() throws ioexception

//獲取文件

@test

public void testgetdocument() throws ioexception }

system.out.println(document.tostring());

//獲得乙個map 我們上面testcreatedocument方法存的值

system.out.println(document.getsourceasmap());

//獲取指定的key對應的val

object name = document.getsource().get("name");

system.out.println(name);

}//更新文件

@test

public void testupdatedocument() throws ioexception

//刪除文件

@test

public void testdeletedocument() throws ioexception

//批量新增文件 專案真實場景

@test

public void testbulkrequest() throws ioexception

//執行批量請求

bulkresponse bulk = resthighlevelclient.bulk(bulkrequest, requestoptions.default);

system.out.println(!bulk.hasfailures());返回false成功

}//查詢

//searchsourcebuilder 構建搜尋

//highlightbuilder 構建高亮

//matchallquerybuilder 構建匹配所有

//termquerybuilder 構建匹配

@test

public void testsearch() throws ioexception

}

六 ES增刪改查操作

一 查詢 get test index test type 1 1.source 在建立document的時候,使用的request body中的json串。預設情況下,在get的時候,會原封不動的給我們返回回來。2.查詢指定字段 定製返回的結果,指定 source中,返回哪些field get t...

SpringData整合ES 增刪改查

該示例以product為j abean物件,使用springdata整合es,用productdao對es進行方便的增刪改查 org.springframework.boot spring boot starter parent 2.3.6.release org.projectlombok lom...

mysql增刪改查效果 mysql增刪改查

檢視所有資料庫 mysql show databases 建立乙個庫ghd並指定字符集為utp8 mysql create database ghd charset utf8 檢視mysql支援的字符集 mysql show char set 建立乙個表,並設定id為主鍵 create table ...