feat(新增): 删除文档

This commit is contained in:
bunny 2024-03-31 20:52:09 +08:00
parent 83268e5e36
commit f78044ec40
2 changed files with 11 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.service.IHotelService;
import com.alibaba.fastjson.JSON;
import org.apache.http.HttpHost;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
@ -76,9 +77,18 @@ public class HotelDocumentTest {
// 准备请求参数
request.doc(
"price", "666",
"startName", "四钻"
"starName", "四钻"
);
// 发送请求
client.update(request, RequestOptions.DEFAULT);
}
// 删除文档
@Test
void testDeleteDocument() throws IOException {
// 准备Request
DeleteRequest request = new DeleteRequest("hotel", "61083");
// 发送请求
client.delete(request, RequestOptions.DEFAULT);
}
}