xuanyuan1hao opened a new issue #7152:
URL: https://github.com/apache/skywalking/issues/7152


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   - [*] Bug
   - [ ] Requirement
   - [ ] Feature or performance improvement
   
   ___
   ### Question
   - skywalking会创建太多的索引库,我这里进行了代码修改,删除一天以前历史记录中文档数量为0的索引库。
   
   ### Requirement or improvement
   - 修改代码:HistoryDeleteEsDAO .java 
   - long  deadline2 = Long.parseLong(new 
DateTime().plusDays(-1).toString("yyyyMMdd"));
   -  for (String index : indexes) {
               long timeSeries = 
TimeSeriesUtils.isolateTimeFromIndexName(index);
               if (deadline >= timeSeries||(client.indexDocIsZero(tableName) && 
deadline2>= timeSeries)) {
                   prepareDeleteIndexes.add(index);
               } else {
                   leftIndices.add(index);
               }
           }
   - 
   修改代码:ElasticSearchClient.java
   
   public boolean indexDocIsZero(String tableName) throws IOException {
           SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
           SearchRequest rq = new SearchRequest();
           //索引
           rq.indices(tableName);
           //各种组合条件
           rq.source(sourceBuilder);
           //其实位置
           sourceBuilder.from(0);
           //每页数量
           sourceBuilder.size(1);
           SearchResponse search = client.search(rq);
           return search.getHits().totalHits==0;
       }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to