ASTERIXDB-1088: fixed a secondary index compact issue

 - Secondary index is now properly compacted

Change-Id: Ide9191fce61b767c08d2298070e64d455ee34f0b
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1123
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Taewoo Kim <wangsaeu@yahoo.com>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 24c678c..6390b9d 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -2487,9 +2487,14 @@
             if (ds.getDatasetType() == DatasetType.INTERNAL) {
                 for (int j = 0; j < indexes.size(); j++) {
                     if (indexes.get(j).isSecondaryIndex()) {
-                        jobsToExecute
-                                .add(DatasetOperations.compactDatasetJobSpec(
-                                        dataverse, datasetName, metadataProvider));
+                        CompiledIndexCompactStatement cics = new CompiledIndexCompactStatement(dataverseName,
+                                datasetName, indexes.get(j).getIndexName(), indexes.get(j).getKeyFieldNames(),
+                                indexes.get(j).getKeyFieldTypes(), indexes.get(j).isEnforcingKeyFileds(),
+                                indexes.get(j).getGramLength(), indexes.get(j).getIndexType());
+                        List<Integer> keySourceIndicators = indexes.get(j).getKeyFieldSourceIndicators();
+
+                        jobsToExecute.add(IndexOperations.buildSecondaryIndexCompactJobSpec(cics, aRecordType,
+                                metaRecordType, keySourceIndicators, enforcedType, metadataProvider));
                     }
                 }
             } else {