1. 目标
拿自己5000条电器商品库与10w条美的商品库 在 elasticsearch6.8.8
中进行匹配 检索相似度最高的项目
2. excel 导入数据
使用easyexcel读取excel 使用bulkrequest 导入es
3. 测试依据id获取数据
HttpHost httpHost = new HttpHost("localhost", 9200, "http");
RestClientBuilder builder = RestClient.builder(httpHost);
RestHighLevelClient restHighLevelClient = new RestHighLevelClient(builder);
// 参数分别为index type id
GetRequest getRequest = new GetRequest("whole", "doc", "31022316000184");
try {
GetResponse response = restHighLevelClient.get(getRequest, RequestOptions.DEFAULT);
System.out.println(response.toString());
String exist = response.getSourceAsString();
System.out.println(exist);
restHighLevelClient.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
restHighLevelClient.close();
} catch (IOException ignored) {
}
}