Commit 7e7fe1a3 by gxfeng

更换es配置打包发版

parent 8af604ee
package com.example.aliossjava.common;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
......@@ -16,7 +17,6 @@ import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;
import java.util.*;
......@@ -59,13 +59,13 @@ public class CompanyNameUtils {
* @return
*/
public static Map<String,Object> querycompanyNanme(String fieldKey, String fieldnum, Integer from, Integer size) throws Exception {
if (fieldnum == null || "".equals(fieldnum)){
if (fieldnum == null || "".equals(fieldnum)) {
fieldnum = "不限";
}
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("elastic", "w3OL+51eo*)c=^7"));
RestClientBuilder client = RestClient.builder(new HttpHost("es-cn-zz11nl9y20001gczg.public.elasticsearch.aliyuncs.com", 9200))
new UsernamePasswordCredentials("elastic", "8TtEiDHHh2N8FFrVkADH"));
RestClientBuilder client = RestClient.builder(new HttpHost("es-bp.gongsibao.com", 443, "https"))
.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
......@@ -73,7 +73,7 @@ public class CompanyNameUtils {
}
});
RestHighLevelClient restClient = new RestHighLevelClient(client);
SearchRequest searchRequest = new SearchRequest("treasure_name");
SearchRequest searchRequest = new SearchRequest("check_name_treasure_name_2020_10_28");
searchRequest.types("_doc");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
if (fieldnum.equals("不限") && fieldKey.equals("")) {
......@@ -102,14 +102,13 @@ public class CompanyNameUtils {
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = restClient.search(searchRequest, RequestOptions.DEFAULT);
List<String> result = new LinkedList<>();
SearchHits searchHits=searchResponse.getHits();
SearchHits searchHits = searchResponse.getHits();
HashMap<String, Object> hashMap = new HashMap<>();
searchHits.forEach(i->{
searchHits.forEach(i -> {
result.add(i.getSourceAsString());
});
hashMap.put("companyName",result);
hashMap.put("count",searchHits.getTotalHits().value);
hashMap.put("companyName", result);
hashMap.put("count", searchHits.getTotalHits().value);
return hashMap;
}
}
com\example\aliossjava\common\CompanyNameUtils.class
com\example\aliossjava\common\TestUploadOssApi.class
com\example\aliossjava\controller\UploadController.class
com\example\aliossjava\common\UploadUtils.class
com\example\aliossjava\common\CompanyNameUtils$1.class
com\example\aliossjava\AliossJavaApplication.class
com\example\aliossjava\controller\CompanyNameController.class
com\example\aliossjava\common\AESUtils.class
-------------------------------------------------------------------------------
Test set: com.example.aliossjava.AliossJavaApplicationTests
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.816 s - in com.example.aliossjava.AliossJavaApplicationTests
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.583 s - in com.example.aliossjava.AliossJavaApplicationTests
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment