add:升级es到7.6.2
This commit is contained in:
+22
-11
@@ -4,21 +4,21 @@ import com.adc.da.base.web.BaseController;
|
||||
import com.adc.da.excel.poi.excel.ExcelExportUtil;
|
||||
import com.adc.da.excel.poi.excel.entity.ExportParams;
|
||||
import com.adc.da.excel.poi.excel.entity.enums.ExcelType;
|
||||
import com.adc.da.exception.AdcDaBaseException;
|
||||
import com.adc.da.http.PageInfo;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.person.service.IPersonCollectEOService;
|
||||
import com.adc.da.search.dto.*;
|
||||
import com.adc.da.search.dto.SearchBussExportDto;
|
||||
import com.adc.da.search.dto.SearchLawsExportDto;
|
||||
import com.adc.da.search.dto.SearchMsgExportDto;
|
||||
import com.adc.da.search.dto.SearchStandExportDto;
|
||||
import com.adc.da.search.entity.CommonSearchInfoEO;
|
||||
import com.adc.da.search.entity.SarAdvanceSearchVO;
|
||||
import com.adc.da.search.entity.SeniorSearchInfoEO;
|
||||
import com.adc.da.search.service.ElasticsearchService;
|
||||
import com.adc.da.search.service.SearchCenterService;
|
||||
import com.adc.da.exception.AdcDaBaseException;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.tsDictionaryType.entity.TsSearchMenu;
|
||||
import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService;
|
||||
import com.adc.da.util.IOUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -26,14 +26,25 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.adc.da.sys.common.ReadExcelName.encodeFileName;
|
||||
|
||||
@RestController
|
||||
@@ -52,14 +63,14 @@ public class SearchCenterController extends BaseController<Map<String, Object>>
|
||||
@Autowired
|
||||
private ElasticsearchService elasticsearchService;
|
||||
|
||||
@Autowired
|
||||
/*@Autowired
|
||||
private ITsDicTypeService iTsDictypeService;
|
||||
|
||||
@ApiOperation("获取筛选条件")
|
||||
@PostMapping("/getMenu")
|
||||
public ResponseMessage<List<TsSearchMenu>> getSearchMenu(){
|
||||
return Result.success(iTsDictypeService.getSearchMenu());
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
+15
-11
@@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
|
||||
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||
@@ -19,6 +18,7 @@ import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.elasticsearch.action.update.UpdateResponse;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
@@ -26,15 +26,13 @@ import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.reindex.BulkByScrollResponse;
|
||||
import org.elasticsearch.index.reindex.DeleteByQueryAction;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
||||
import org.elasticsearch.search.aggregations.metrics.avg.Avg;
|
||||
import org.elasticsearch.search.aggregations.metrics.max.Max;
|
||||
import org.elasticsearch.search.aggregations.metrics.Avg;
|
||||
import org.elasticsearch.search.aggregations.metrics.Max;
|
||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.slf4j.Logger;
|
||||
@@ -43,7 +41,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
public class ElasticsearchServiceImpl implements ElasticsearchService {
|
||||
@@ -89,7 +91,8 @@ public class ElasticsearchServiceImpl implements ElasticsearchService {
|
||||
if (!isIndexExist(index)) {
|
||||
logger.info("Index is not exits!");
|
||||
}
|
||||
DeleteIndexResponse dResponse = client.admin().indices().prepareDelete(index).get();
|
||||
AcknowledgedResponse dResponse = client.admin().indices().prepareDelete(index).get();
|
||||
|
||||
if (dResponse.isAcknowledged()) {
|
||||
logger.info("delete index " + index + " successfully!");
|
||||
} else {
|
||||
@@ -184,13 +187,14 @@ public class ElasticsearchServiceImpl implements ElasticsearchService {
|
||||
*/
|
||||
@Override
|
||||
public long deleteAllDataOfIndex(String index) {
|
||||
BulkByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client)
|
||||
/*BulkByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client)
|
||||
.filter(QueryBuilders.matchAllQuery())
|
||||
.source(index)
|
||||
.get();
|
||||
//一共删除掉多少条
|
||||
long deleted = response.getDeleted();
|
||||
return deleted;
|
||||
return deleted;*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,7 +394,7 @@ public class ElasticsearchServiceImpl implements ElasticsearchService {
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
long totalHits = searchResponse.getHits().totalHits;
|
||||
long totalHits = searchResponse.getHits().getTotalHits().value;
|
||||
long length = searchResponse.getHits().getHits().length;
|
||||
|
||||
logger.info("共查询到[{}]条数据,处理数据条数[{}]", totalHits, length);
|
||||
@@ -488,7 +492,7 @@ public class ElasticsearchServiceImpl implements ElasticsearchService {
|
||||
// 执行搜索,返回搜索响应信息
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
long totalHits = searchResponse.getHits().totalHits;
|
||||
long totalHits = searchResponse.getHits().getTotalHits().value;
|
||||
long length = searchResponse.getHits().getHits().length;
|
||||
|
||||
logger.debug("共查询到[{}]条数据,处理数据条数[{}]", totalHits, length);
|
||||
|
||||
+3
-3
@@ -807,7 +807,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
|
||||
// 获取查询到的结果
|
||||
SearchResponse response = searchRequestBuilder.get();
|
||||
result = SearchResponseToList(response);
|
||||
searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits());
|
||||
searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits().value);
|
||||
Map<String, Aggregation> aggmap = response.getAggregations().asMap();
|
||||
if (!result.isEmpty()) {
|
||||
for (int i = 0; i < seniortype.length; i++) {
|
||||
@@ -1158,7 +1158,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
|
||||
// }
|
||||
result.add(sourceAsMap);
|
||||
}
|
||||
searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits());
|
||||
searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits().value);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1243,7 +1243,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
|
||||
}
|
||||
result.add(sourceAsMap);
|
||||
}
|
||||
searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits());
|
||||
searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits().value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user