Program: 34497
Project: 34497
Buggy source:
/** 
 * 官网上的 【Top Hits Aggregation】 JAVA API 运行报错，
 * @see https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_metrics_aggregations.html<pre> {@code AggregationBuilder aggregation = AggregationBuilders .terms("agg").field("gender") .subAggregation( AggregationBuilders.topHits("top") .explain(true) .size(1) .from(10) );}</pre> Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene50' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: [completion, completion090] <p> 以下满足张真要求的ES的查询可以工作，但找不到对应的JAVA API（原因在上）？？！！！ <pre>  {@code}{ "aggs": { "time": { "terms": { "field": "time", "order":{"_term":"desc"}, "size": 1000 }, "aggs": { "example": { "top_hits": { "sort": [ { "percpu": { "order": "desc" } } ], "size": 1 } } } } }, "from": 0, "size": 0 } } </pre>
 * @param data
 */
private void queryDistinct(UAVHttpMessage data){
  try {
    String ipport=data.getRequest("String_Node_Str");
    AggregationBuilder agg=AggregationBuilders.terms("String_Node_Str").field("String_Node_Str").order(Terms.Order.term(false)).subAggregation(AggregationBuilders.terms("String_Node_Str").field("String_Node_Str"));
    String date=data.getRequest("String_Node_Str");
    String currentIndex;
    if (date != null) {
      currentIndex=this.indexMgr.getIndexByDate(date);
    }
 else {
      currentIndex=this.indexMgr.getCurrentIndex();
    }
    SearchResponse sResponse=client.getClient().prepareSearch(currentIndex).setTypes(ThreadAnalysisIndexMgr.JTA_TABLE).setQuery(QueryBuilders.boolQuery().must(QueryBuilders.termQuery("String_Node_Str",ipport))).setSize(0).addAggregation(agg).execute().actionGet();
    Terms aggs=sResponse.getAggregations().get("String_Node_Str");
    List<Map<String,Object>> records=new ArrayList<Map<String,Object>>();
    for (    Terms.Bucket entry : aggs.getBuckets()) {
      String key=entry.getKey().toString();
      long docCount=entry.getDocCount();
      Map<String,Object> record=new HashMap<String,Object>();
      record.put("String_Node_Str",key);
      record.put("String_Node_Str",docCount);
      Terms userAggs=entry.getAggregations().get("String_Node_Str");
      List<Terms.Bucket> users=userAggs.getBuckets();
      if (!users.isEmpty()) {
        record.put("String_Node_Str",users.get(0).getKey().toString());
      }
      records.add(record);
    }
    data.putResponse("String_Node_Str",JSONHelper.toString(records));
    data.putResponse("String_Node_Str",aggs.getBuckets().size() + "String_Node_Str");
  }
 catch (  Exception e) {
    if (e.getMessage().indexOf("String_Node_Str") >= 0) {
      data.putResponse("String_Node_Str","String_Node_Str");
    }
 else {
      data.putResponse("String_Node_Str","String_Node_Str");
      log.err(this,"String_Node_Str" + JSONHelper.toString(data),e);
    }
  }
}

Fixed version (ground truth):
/** 
 * 官网上的 【Top Hits Aggregation】 JAVA API 运行报错，
 * @see https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_metrics_aggregations.html<pre> {@code AggregationBuilder aggregation = AggregationBuilders .terms("agg").field("gender") .subAggregation( AggregationBuilders.topHits("top") .explain(true) .size(1) .from(10) );}</pre> Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene50' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: [completion, completion090] <p> 以下满足张真要求的ES的查询可以工作，但找不到对应的JAVA API（原因在上）？？！！！ <pre>  {@code}{ "aggs": { "time": { "terms": { "field": "time", "order":{"_term":"desc"}, "size": 1000 }, "aggs": { "example": { "top_hits": { "sort": [ { "percpu": { "order": "desc" } } ], "size": 1 } } } } }, "from": 0, "size": 0 } } </pre>
 * @param data
 */
private void queryDistinct(UAVHttpMessage data){
  try {
    String ipport=data.getRequest("String_Node_Str");
    AggregationBuilder agg=AggregationBuilders.terms("String_Node_Str").field("String_Node_Str").size(1000).order(Terms.Order.term(false)).subAggregation(AggregationBuilders.terms("String_Node_Str").field("String_Node_Str").size(1000));
    String date=data.getRequest("String_Node_Str");
    String currentIndex;
    if (date != null) {
      currentIndex=this.indexMgr.getIndexByDate(date);
    }
 else {
      currentIndex=this.indexMgr.getCurrentIndex();
    }
    SearchResponse sResponse=client.getClient().prepareSearch(currentIndex).setTypes(ThreadAnalysisIndexMgr.JTA_TABLE).setQuery(QueryBuilders.boolQuery().must(QueryBuilders.termQuery("String_Node_Str",ipport))).setSize(0).addAggregation(agg).execute().actionGet();
    Terms aggs=sResponse.getAggregations().get("String_Node_Str");
    List<Map<String,Object>> records=new ArrayList<Map<String,Object>>();
    for (    Terms.Bucket entry : aggs.getBuckets()) {
      String key=entry.getKey().toString();
      long docCount=entry.getDocCount();
      Map<String,Object> record=new HashMap<String,Object>();
      record.put("String_Node_Str",key);
      record.put("String_Node_Str",docCount);
      Terms userAggs=entry.getAggregations().get("String_Node_Str");
      List<Terms.Bucket> users=userAggs.getBuckets();
      if (!users.isEmpty()) {
        record.put("String_Node_Str",users.get(0).getKey().toString());
      }
      records.add(record);
    }
    data.putResponse("String_Node_Str",JSONHelper.toString(records));
    data.putResponse("String_Node_Str",aggs.getBuckets().size() + "String_Node_Str");
  }
 catch (  Exception e) {
    if (e.getMessage().indexOf("String_Node_Str") >= 0) {
      data.putResponse("String_Node_Str","String_Node_Str");
    }
 else {
      data.putResponse("String_Node_Str","String_Node_Str");
      log.err(this,"String_Node_Str" + JSONHelper.toString(data),e);
    }
  }
}