You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2016/09/27 19:54:41 UTC

[1/7] ambari git commit: AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Repository: ambari
Updated Branches:
  refs/heads/branch-dev-logsearch 3013589a1 -> ea644cc43


http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DownloadUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DownloadUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DownloadUtil.java
new file mode 100644
index 0000000..3fd4b45
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DownloadUtil.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest;
+import org.apache.ambari.logsearch.model.response.BarGraphData;
+import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.NameValueData;
+import org.apache.ambari.logsearch.model.response.TemplateData;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LINE_NUMBER;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOG_MESSAGE;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGGER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.THREAD_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.FILE;
+
+
+public class DownloadUtil {
+
+  private DownloadUtil() {
+    throw new UnsupportedOperationException();
+  }
+
+  public static void fillModelsForLogFile(SolrDocumentList docList, Map<String, Object> models, ServiceLogExportRequest request,
+                                          String format, String from, String to) {
+    long numLogs = docList.getNumFound();
+    List<String> hosts = new ArrayList<>();
+    List<String> components = new ArrayList<>();
+    List<String> levels = new ArrayList<>();
+    List<TemplateData> logData = new ArrayList<>();
+    for (SolrDocument doc : docList) {
+      if (doc != null) {
+        String hostname = (String) doc.getFieldValue(HOST);
+        String comp = (String) doc.getFieldValue(COMPONENT);
+        String level = (String) doc.getFieldValue(LEVEL);
+
+        if (!hosts.contains(hostname)) {
+          hosts.add(hostname);
+        }
+
+        if (!components.contains(comp)) {
+          components.add(comp);
+        }
+
+        if (!levels.contains(level)) {
+          levels.add(level);
+        }
+
+        StringBuffer textToWrite = new StringBuffer();
+
+        if (doc.getFieldValue(LOGTIME) != null) {
+          textToWrite.append(doc.getFieldValue(LOGTIME).toString() + " ");
+        }
+        if (doc.getFieldValue(LEVEL) != null) {
+          textToWrite.append(doc.getFieldValue(LEVEL).toString()).append(" ");
+        }
+        if (doc.getFieldValue(THREAD_NAME) != null) {
+          textToWrite.append(doc.getFieldValue(THREAD_NAME).toString().trim()).append(" ");
+        }
+        if (doc.getFieldValue(LOGGER_NAME) != null) {
+          textToWrite.append(doc.getFieldValue(LOGGER_NAME).toString().trim()).append(" ");
+        }
+        if (doc.getFieldValue(FILE) != null && doc.getFieldValue(LINE_NUMBER) != null) {
+          textToWrite
+            .append(doc.getFieldValue(FILE).toString())
+            .append(":")
+            .append(doc.getFieldValue(LINE_NUMBER).toString())
+            .append(" ");
+        }
+        if (doc.getFieldValue(LOG_MESSAGE) != null) {
+          textToWrite.append("- ")
+            .append(doc.getFieldValue(LOG_MESSAGE).toString());
+        }
+        logData.add(new TemplateData((textToWrite.toString())));
+      }
+    }
+    models.put("numberOfLogs", numLogs);
+    models.put("logs", logData);
+    models.put("hosts", "[ " + StringUtils.join(hosts, " ; ") + " ]");
+    models.put("components", "[ " + StringUtils.join(components, " ; ") + " ]");
+    models.put("format", format);
+    models.put("from", from);
+    models.put("levels", StringUtils.join(levels, ", "));
+    models.put("to", to);
+    String includeString = request.getiMessage();
+    if (StringUtils.isBlank(includeString)) {
+      includeString = "\"\"";
+    } else {
+      List<String> include = Splitter.on(request.getiMessage()).splitToList(LogSearchConstants.I_E_SEPRATOR);
+      includeString = "\"" + StringUtils.join(include, "\", \"") + "\"";
+    }
+    models.put("iString", includeString);
+
+    String excludeString = request.geteMessage();
+    if (StringUtils.isBlank(excludeString)) {
+      excludeString = "\"\"";
+    } else {
+      List<String> exclude = Splitter.on(request.getiMessage()).splitToList(LogSearchConstants.I_E_SEPRATOR);
+      excludeString = "\"" + StringUtils.join(exclude, "\", \"") + "\"";
+    }
+    models.put("eString", excludeString);
+  }
+
+  public static void fillUserResourcesModel(Map<String, Object> models, BarGraphDataListResponse vBarUserDataList, BarGraphDataListResponse vBarResourceDataList) {
+    List<TemplateData> usersDataList = new ArrayList<>();
+    List<TemplateData> resourceDataList = new ArrayList<>();
+    Collection<BarGraphData> tableUserData = vBarUserDataList.getGraphData();
+    for (BarGraphData graphData : tableUserData) {
+      String userName = graphData.getName().length() > 45 ? graphData.getName().substring(0, 45) : graphData.getName();
+      Collection<NameValueData> vnameValueList = graphData.getDataCount();
+      usersDataList.add(new TemplateData(appendNameValueData(addBlank(userName), vnameValueList)));
+    }
+    Collection<BarGraphData> tableResourceData = vBarResourceDataList.getGraphData();
+    for (BarGraphData graphData : tableResourceData) {
+      String resourceName = graphData.getName().length() > 45 ? graphData.getName().substring(0, 45) : graphData.getName();
+      Collection<NameValueData> vnameValueList = graphData.getDataCount();
+      resourceDataList.add(new TemplateData(appendNameValueData(addBlank(resourceName), vnameValueList)));
+    }
+    models.put("users", usersDataList);
+    models.put("resources", resourceDataList);
+    models.put("usersSummary", vBarUserDataList.getGraphData().size());
+    models.put("resourcesSummary", vBarResourceDataList.getGraphData().size());
+  }
+
+  private static String appendNameValueData(String data, Collection<NameValueData> vnameValueList) {
+    int count = 0;
+    String blank = "";
+    for (NameValueData vNameValue : vnameValueList) {
+      data += blank + vNameValue.getName() + " " + vNameValue.getValue();
+      if (count == 0)
+        blank = addBlank(blank);
+      count++;
+    }
+    return data;
+  }
+
+  private static String addBlank(String field) {
+    int blanks = 50;
+    int strSize = field.length();
+    String fieldWithBlank = field;
+    for (int i = 0; i < blanks - strSize; i++) {
+      fieldWithBlank += " ";
+    }
+    return fieldWithBlank;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java
index 505b74d..f7330fa 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java
@@ -19,19 +19,9 @@
 
 package org.apache.ambari.logsearch.util;
 
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
 import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
 import java.net.URL;
-import java.util.List;
-import java.util.Set;
 
-import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.view.VHost;
-import org.apache.ambari.logsearch.view.VSummary;
 import org.apache.log4j.Logger;
 
 public class FileUtil {
@@ -40,80 +30,6 @@ public class FileUtil {
   private FileUtil() {
     throw new UnsupportedOperationException();
   }
-  
-  public static Response saveToFile(String text, String fileName, VSummary vsummary) {
-    String mainExportedFile = "";
-    FileOutputStream fis = null;
-    try {
-      mainExportedFile = mainExportedFile + "**********************Summary**********************\n";
-      mainExportedFile = mainExportedFile + "Number of Logs : " + vsummary.getNumberLogs() + "\n";
-      mainExportedFile = mainExportedFile + "From           : " + vsummary.getFrom() + "\n";
-      mainExportedFile = mainExportedFile + "To             : " + vsummary.getTo() + "\n";
-
-      List<VHost> hosts = vsummary.getHosts();
-      String blankCharacterForHost = String.format("%-8s", "");
-      int numberHost = 0;
-      for (VHost host : hosts) {
-        numberHost += 1;
-        String h = host.getName();
-        String c = "";
-        Set<String> comp = host.getComponents();
-        boolean zonetar = true;
-        if (comp != null) {
-          for (String component : comp) {
-            if (zonetar) {
-              c = component;
-              zonetar = false;
-            } else {
-              c = c + ", " + component;
-            }
-          }
-        }
-        if (numberHost > 9){
-          blankCharacterForHost = String.format("%-7s", blankCharacterForHost);
-        }else if (numberHost > 99){
-          blankCharacterForHost = String.format("%-6s", blankCharacterForHost);
-        }else if (numberHost > 999){
-          blankCharacterForHost = String.format("%-5s", blankCharacterForHost);
-        }else if (numberHost > 9999){
-          blankCharacterForHost = String.format("%-4s", blankCharacterForHost);
-        }else if (numberHost > 99999){
-          blankCharacterForHost = String.format("%-3s", blankCharacterForHost);
-        }
-        if (numberHost == 1) {
-          mainExportedFile = mainExportedFile + "Host" + blankCharacterForHost + "   : " + h + " [" + c + "] " + "\n";
-        } else if (numberHost > 1) {
-          mainExportedFile = mainExportedFile + "Host_" + numberHost + blankCharacterForHost + " : " + h + " [" + c + "] " + "\n";
-        }
-
-      }
-      mainExportedFile = mainExportedFile + "Levels"+String.format("%-9s", blankCharacterForHost)+": " + vsummary.getLevels() + "\n";
-      mainExportedFile = mainExportedFile + "Format"+String.format("%-9s", blankCharacterForHost)+": " + vsummary.getFormat() + "\n";
-      mainExportedFile = mainExportedFile + "\n";
-
-      mainExportedFile = mainExportedFile + "Included String: [" + vsummary.getIncludeString() + "]\n\n";
-      mainExportedFile = mainExportedFile + "Excluded String: [" + vsummary.getExcludeString() + "]\n\n";
-      mainExportedFile = mainExportedFile + "************************Logs***********************" + "\n";
-      mainExportedFile = mainExportedFile + text + "\n";
-      File file = File.createTempFile(fileName, vsummary.getFormat());
-      fis = new FileOutputStream(file);
-      fis.write(mainExportedFile.getBytes());
-      return Response
-        .ok(file, MediaType.APPLICATION_OCTET_STREAM)
-        .header("Content-Disposition", "attachment;filename=" + fileName + vsummary.getFormat())
-        .build();
-    } catch (Exception e) {
-      logger.error(e.getMessage());
-      throw RESTErrorUtil.createRESTException(e.getMessage(), MessageEnums.ERROR_SYSTEM);
-    } finally {
-      if (fis != null) {
-        try {
-          fis.close();
-        } catch (IOException e) {
-        }
-      }
-    }
-  }
 
   public static File getFileFromClasspath(String filename) {
     URL fileCompleteUrl = Thread.currentThread().getContextClassLoader().getResource(filename);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java
index 33262f3..c67cf27 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java
@@ -19,146 +19,45 @@
 
 package org.apache.ambari.logsearch.util;
 
-import java.util.Collection;
 import java.util.HashMap;
-import java.util.Locale;
+import java.util.Map;
 
 import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
+import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
+import org.apache.lucene.analysis.path.PathHierarchyTokenizerFactory;
+import org.apache.lucene.analysis.standard.StandardTokenizerFactory;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.schema.TrieDoubleField;
 import org.apache.solr.schema.TrieFloatField;
 import org.apache.solr.schema.TrieIntField;
 import org.apache.solr.schema.TrieLongField;
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
-import org.springframework.util.CollectionUtils;
 
 public class SolrUtil {
   private SolrUtil() {
     throw new UnsupportedOperationException();
   }
-  
-  public static String setField(String fieldName, String value) {
-    if (value == null || value.trim().length() == 0) {
-      return "";
-    }
-    return fieldName + ":" + value.trim().toLowerCase(Locale.ENGLISH);
-  }
-
-  public static String inList(String fieldName, int[] values) {
-    if (ArrayUtils.isEmpty(values)) {
-      return "";
-    }
-    String expr = "";
-    // Add the filter queries
-    for (int i : values) {
-      expr += i + " ";
-    }
-    if (values.length == 0) {
-      return fieldName + ":" + expr;
-    } else {
-      return fieldName + ":(" + expr + ")";
-    }
-  }
-
-  public static String inList(Collection<Long> values) {
-    if (CollectionUtils.isEmpty(values)) {
-      return "";
-    }
-    String expr = "";
-    for (Long value : values) {
-      expr += value.toString() + " ";
-    }
-
-    if (values.isEmpty()) {
-      return expr.trim();
-    } else {
-      return "(" + expr.trim() + ")";
-    }
-
-  }
-
-  public static String orList(String fieldName, String[] valueList, String wildCard) {
-    if (ArrayUtils.isEmpty(valueList)) {
-      return "";
-    }
-    
-    if (StringUtils.isBlank(wildCard)) {
-      wildCard = "";
-    }
-    
-    StringBuilder expr = new StringBuilder();
-    int count = -1;
-    for (String value : valueList) {
-      count++;
-      if (count > 0) {
-        expr.append(" OR ");
-      }
-      
-      expr.append( fieldName + ":"+ wildCard + value + wildCard);
-
-    }
-    if (valueList.length == 0) {
-      return expr.toString();
-    } else {
-      return "(" + expr + ")";
-    }
-
-  }
-
-  public static String andList(String fieldName, String[] valueList, String wildCard) {
-    if (ArrayUtils.isEmpty(valueList)) {
-      return "";
-    }
-    
-    if (StringUtils.isBlank(wildCard)) {
-      wildCard = "";
-    }
-    
-    StringBuilder expr = new StringBuilder();
-    int count = -1;
-    for (String value : valueList) {
-      count++;
-      if (count > 0) {
-        expr.append(" AND ");
-      }
-      
-      expr.append( fieldName + ":"+ wildCard + value + wildCard);
-
-    }
-    if (valueList.length == 0) {
-      return expr.toString();
-    } else {
-      return "(" + expr + ")";
-    }
-
-  }
 
   /**
    * Copied from Solr ClientUtils.escapeQueryChars and removed escaping *
    */
   public static String escapeQueryChars(String s) {
     StringBuilder sb = new StringBuilder();
-    int prev = 0;
     if (s != null) {
       for (int i = 0; i < s.length(); i++) {
         char c = s.charAt(i);
-        int ic = (int)c;
-        if( ic == 10 ) {
-          if( prev != 13) {
-            //Let's insert \r
-            sb.append('\\');
-            sb.append((char)13);
-          }
+        int ic = (int) c;
+        if (ic == 10) {
+          sb.append('\\');
+          sb.append((char) 13);
         }
         // Note: Remove || c == '*'
         // These characters are part of the query syntax and must be escaped
         if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '('
-            || c == ')' || c == ':' || c == '^' || c == '[' || c == ']'
-            || c == '\"' || c == '{' || c == '}' || c == '~' || c == '?'
-            || c == '|' || c == '&' || c == ';' || c == '/'
-            || Character.isWhitespace(c)) {
+          || c == ')' || c == ':' || c == '^' || c == '[' || c == ']'
+          || c == '\"' || c == '{' || c == '}' || c == '~' || c == '?'
+          || c == '|' || c == '&' || c == ';' || c == '/'
+          || Character.isWhitespace(c)) {
           sb.append('\\');
         }
         sb.append(c);
@@ -167,25 +66,6 @@ public class SolrUtil {
     return sb.toString();
   }
 
-  private static String escapeForWhiteSpaceTokenizer(String search) {
-    if (search == null) {
-      return null;
-    }
-    String newString = search.trim();
-    String newSearch = escapeQueryChars(newString);
-    boolean isSingleWord = true;
-    for (int i = 0; i < search.length(); i++) {
-      if (Character.isWhitespace(search.charAt(i))) {
-        isSingleWord = false;
-      }
-    }
-    if (!isSingleWord) {
-      newSearch = "\"" + newSearch + "\"";
-    }
-
-    return newSearch;
-  }
-
   public static String escapeForStandardTokenizer(String search) {
     if (search == null) {
       return null;
@@ -224,16 +104,14 @@ public class SolrUtil {
    * This is a special case scenario to handle log_message for wild card
    * scenarios
    */
-  public static String escapeForLogMessage(String field, String search) {
+  public static String escapeForLogMessage(String search) {
     if (search.startsWith("*") && search.endsWith("*")) {
-      field = LogSearchConstants.SOLR_KEY_LOG_MESSAGE;
       search = escapeForKeyTokenizer(search);
     } else {
       // Use whitespace index
-      field = LogSearchConstants.SOLR_LOG_MESSAGE;
-      search = escapeForWhiteSpaceTokenizer(search);
+      search = escapeForStandardTokenizer(search);
     }
-    return field + ":" + search;
+    return search;
   }
 
   public static String makeSolrSearchString(String search) {
@@ -270,11 +148,11 @@ public class SolrUtil {
   }
   
 
-  public static boolean isSolrFieldNumber(String fieldType,SolrDaoBase solrDaoBase) {
+  public static boolean isSolrFieldNumber(String fieldType, Map<String, String> schemaFieldsMap) {
     if (StringUtils.isBlank(fieldType)) {
       return false;
     } else {
-      HashMap<String, Object> typeInfoMap = getFieldTypeInfoMap(fieldType,solrDaoBase);
+      HashMap<String, Object> typeInfoMap = getFieldTypeInfoMap(fieldType, schemaFieldsMap);
       if (typeInfoMap == null || typeInfoMap.isEmpty()) {
         return false;
       }
@@ -294,12 +172,63 @@ public class SolrUtil {
       return false;
     }
   }
+
+  public static String putWildCardByType(String str, String key, Map<String, String> schemaFieldsMap) {
+    String fieldType = schemaFieldsMap.get(key);
+    if (!StringUtils.isBlank(fieldType)) {
+      if (isSolrFieldNumber(fieldType, schemaFieldsMap)) {
+        String value = putEscapeCharacterForNumber(str, fieldType, schemaFieldsMap);
+        if (!StringUtils.isBlank(value)) {
+          return value;
+        } else {
+          return null;
+        }
+      } else if (checkTokenizer(fieldType, StandardTokenizerFactory.class, schemaFieldsMap)) {
+        return escapeForStandardTokenizer(str);
+      } else if (checkTokenizer(fieldType, KeywordTokenizerFactory.class, schemaFieldsMap)|| "string".equalsIgnoreCase(fieldType)) {
+        return makeSolrSearchStringWithoutAsterisk(str);
+      } else if (checkTokenizer(fieldType, PathHierarchyTokenizerFactory.class, schemaFieldsMap)) {
+        return str;
+      }
+    }
+    return str;
+  }
+
+  private static String putEscapeCharacterForNumber(String str,String fieldType, Map<String, String> schemaFieldsMap) {
+    if (!StringUtils.isBlank(str)) {
+      str = str.replace("*", "");
+    }
+    String escapeCharSting = parseInputValueAsPerFieldType(str,fieldType, schemaFieldsMap);
+    if (escapeCharSting == null || escapeCharSting.isEmpty()) {
+      return null;
+    }
+    escapeCharSting = escapeCharSting.replace("-", "\\-");
+    return escapeCharSting;
+  }
+
+  private static String parseInputValueAsPerFieldType(String str,String fieldType, Map<String, String> schemaFieldsMap) {
+    try {
+      HashMap<String, Object> fieldTypeInfoMap = SolrUtil.getFieldTypeInfoMap(fieldType, schemaFieldsMap);
+      String className = (String) fieldTypeInfoMap.get("class");
+      if (className.equalsIgnoreCase(TrieDoubleField.class.getSimpleName())) {
+        return "" + Double.parseDouble(str);
+      } else if (className.equalsIgnoreCase(TrieFloatField.class.getSimpleName())) {
+        return "" + Float.parseFloat(str);
+      } else if (className.equalsIgnoreCase(TrieLongField.class.getSimpleName())) {
+        return "" + Long.parseLong(str);
+      } else {
+        return "" + Integer.parseInt(str);
+      }
+    } catch (Exception e) {
+      return null;
+    }
+  }
   
-  public static HashMap<String, Object> getFieldTypeInfoMap(String fieldType,SolrDaoBase solrDaoBase) {
-    String fieldTypeMetaData = solrDaoBase.schemaFieldTypeMap.get(fieldType);
+  public static HashMap<String, Object> getFieldTypeInfoMap(String fieldType, Map<String, String> schemaFieldsTypeMap) {
+    String fieldTypeMetaData = schemaFieldsTypeMap.get(fieldType);
     HashMap<String, Object> fieldTypeMap = JSONUtil.jsonToMapObject(fieldTypeMetaData);
     if (fieldTypeMap == null) {
-      return new HashMap<String, Object>();
+      return new HashMap<>();
     }
     String classname = (String) fieldTypeMap.get("class");
     if (!StringUtils.isBlank(classname)) {
@@ -310,8 +239,7 @@ public class SolrUtil {
   }
   
   //=============================================================================================================
-  
-  //Solr Facet Methods
+
   public static void setFacetField(SolrQuery solrQuery, String facetField) {
     solrQuery.setFacet(true);
     setRowCount(solrQuery, 0);
@@ -319,13 +247,6 @@ public class SolrUtil {
     setFacetLimit(solrQuery, -1);
   }
 
-  public static void setJSONFacet(SolrQuery solrQuery, String jsonQuery) {
-    solrQuery.setFacet(true);
-    setRowCount(solrQuery, 0);
-    solrQuery.set(LogSearchConstants.FACET_JSON_FIELD, jsonQuery);
-    setFacetLimit(solrQuery, -1);
-  }
-
   public static void setFacetSort(SolrQuery solrQuery, String sortType) {
     solrQuery.setFacet(true);
     solrQuery.setFacetSort(sortType);
@@ -339,50 +260,10 @@ public class SolrUtil {
     setFacetLimit(solrQuery, -1);
   }
 
-  public static void setFacetDate(SolrQuery solrQuery, String facetField, String from, String to, String unit) {
-    solrQuery.setFacet(true);
-    setRowCount(solrQuery, 0);
-    solrQuery.set(LogSearchConstants.FACET_DATE, facetField);
-    solrQuery.set(LogSearchConstants.FACET_DATE_START, from);
-    solrQuery.set(LogSearchConstants.FACET_DATE_END, to);
-    solrQuery.set(LogSearchConstants.FACET_DATE_GAP, unit);
-    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, 0);
-    setFacetLimit(solrQuery, -1);
-  }
-
-  public static void setFacetRange(SolrQuery solrQuery, String facetField, String from, String to, String unit) {
-    solrQuery.setFacet(true);
-    setRowCount(solrQuery, 0);
-    solrQuery.set(LogSearchConstants.FACET_RANGE, facetField);
-    solrQuery.set(LogSearchConstants.FACET_RANGE_START, from);
-    solrQuery.set(LogSearchConstants.FACET_RANGE_END, to);
-    solrQuery.set(LogSearchConstants.FACET_RANGE_GAP, unit);
-    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, 0);
-    setFacetLimit(solrQuery, -1);
-  }
-
   public static void setFacetLimit(SolrQuery solrQuery, int limit) {
     solrQuery.set("facet.limit", limit);
   }
 
-  //Solr Group Mehtods
-  public static void setGroupField(SolrQuery solrQuery, String groupField, int rows) {
-    solrQuery.set(LogSearchConstants.FACET_GROUP, true);
-    solrQuery.set(LogSearchConstants.FACET_GROUP_FIELD, groupField);
-    solrQuery.set(LogSearchConstants.FACET_GROUP_MAIN, true);
-    setRowCount(solrQuery, rows);
-  }
-
-  //Main Query
-  public static void setMainQuery(SolrQuery solrQuery, String query) {
-    String defalultQuery = "*:*";
-    if (StringUtils.isBlank(query)){
-      solrQuery.setQuery(defalultQuery);
-    }else{
-      solrQuery.setQuery(query);
-    }
-  }
-
   public static void setStart(SolrQuery solrQuery, int start) {
     int defaultStart = 0;
     if (start > defaultStart) {
@@ -392,7 +273,6 @@ public class SolrUtil {
     }
   }
 
-  //Set Number of Rows
   public static void setRowCount(SolrQuery solrQuery, int rows) {
     if (rows > 0) {
       solrQuery.setRows(rows);
@@ -401,18 +281,28 @@ public class SolrUtil {
       solrQuery.remove(LogSearchConstants.SORT);
     }
   }
-
-  //Solr Facet Methods
-  public static void setFacetFieldWithMincount(SolrQuery solrQuery, String facetField, int minCount) {
-    solrQuery.setFacet(true);
-    setRowCount(solrQuery, 0);
-    solrQuery.set(LogSearchConstants.FACET_FIELD, facetField);
-    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, minCount);
-    setFacetLimit(solrQuery, -1);
-  }
   
   public static void setFl(SolrQuery solrQuery,String field){
     solrQuery.set(LogSearchConstants.FL, field);
   }
+
+  private static boolean checkTokenizer(String fieldType, Class tokenizerFactoryClass, Map<String, String> schemaFieldsMap) {
+    HashMap<String, Object> fieldTypeMap = SolrUtil.getFieldTypeInfoMap(fieldType ,schemaFieldsMap);
+    HashMap<String, Object> analyzer = (HashMap<String, Object>) fieldTypeMap.get("analyzer");
+    if (analyzer != null) {
+      HashMap<String, Object> tokenizerMap = (HashMap<String, Object>) analyzer.get("tokenizer");
+      if (tokenizerMap != null) {
+        String tokenizerClass = (String) tokenizerMap.get("class");
+        if (!StringUtils.isEmpty(tokenizerClass)) {
+          tokenizerClass =tokenizerClass.replace("solr.", "");
+          if (tokenizerClass.equalsIgnoreCase(tokenizerFactoryClass
+            .getSimpleName())) {
+            return true;
+          }
+        }
+      }
+    }
+    return false;
+  }
   
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
index 8cd435b..29fd5b2 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
@@ -61,7 +61,6 @@ import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHa
 import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
 import org.apache.hadoop.security.authentication.util.KerberosName;
 import org.springframework.security.web.authentication.WebAuthenticationDetails;
-import org.springframework.stereotype.Component;
 
 public class LogsearchKRBAuthenticationFilter extends LogsearchKrbFilter {
   private static final Logger logger = LoggerFactory.getLogger(LogsearchKRBAuthenticationFilter.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
index 05104b4..d37e545 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
@@ -27,11 +27,11 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.WebAuthenticationDetails;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
+@Named
 public class LogsearchAuthenticationProvider extends
   LogsearchAbstractAuthenticationProvider {
   private static final Logger logger = Logger

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
index a89b5dd..7e146ac 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
 import org.apache.ambari.logsearch.common.ExternalServerClient;
 import org.apache.ambari.logsearch.common.PropertiesHelper;
@@ -34,14 +35,13 @@ import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.AuthenticationException;
-import org.springframework.stereotype.Component;
 
 /**
  * 
  * Authentication provider to authenticate user from external-server using REST
  * call
  */
-@Component
+@Named
 public class LogsearchExternalServerAuthenticationProvider extends
     LogsearchAbstractAuthenticationProvider {
 
@@ -152,10 +152,9 @@ public class LogsearchExternalServerAuthenticationProvider extends
    */
   @SuppressWarnings("static-access")
   private boolean isAllowedRole(String responseJson) {
-    String allowedRoleList[] = PropertiesHelper
-        .getPropertyStringList(ALLOWED_ROLE_PROP);
+    String allowedRoleList[] = PropertiesHelper.getPropertyStringList(ALLOWED_ROLE_PROP);
 
-    List<String> values = new ArrayList<String>();
+    List<String> values = new ArrayList<>();
     JSONUtil.getValuesOfKey(responseJson,
         PRIVILEGE_INFO.PERMISSION_NAME.toString(), values);
     if (values.isEmpty())

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
index dc70b82..51b3547 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
@@ -32,11 +32,11 @@ import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
+@Named
 public class LogsearchFileAuthenticationProvider extends LogsearchAbstractAuthenticationProvider {
 
   private static Logger logger = Logger.getLogger(LogsearchFileAuthenticationProvider.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java
index 52dd66e..ed4d7ef 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java
@@ -30,12 +30,12 @@ import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.security.ldap.authentication.LdapAuthenticationProvider;
 import org.springframework.security.ldap.search.FilterBasedLdapUserSearch;
-import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
+@Named
 public class LogsearchLdapAuthenticationProvider extends
   LogsearchAbstractAuthenticationProvider {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
index 17d099b..400361b 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
@@ -27,11 +27,11 @@ import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.AuthenticationException;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
+@Named
 public class LogsearchSimpleAuthenticationProvider extends LogsearchAbstractAuthenticationProvider {
 
   private static Logger logger = Logger.getLogger(LogsearchSimpleAuthenticationProvider.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties
index 9a44761..c98a482 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties
@@ -24,4 +24,3 @@ logsearch.logfeeder.include.default.level=FATAL,ERROR,WARN,INFO,DEBUG,TRACE
 #login config
 logsearch.login.credentials.file=user_pass.json
 logsearch.login.ldap.config=logsearch-admin-site.xml
-logsearch.solr.warming.cron=0 0/10 * * * ?

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/audit_log_txt.ftl
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/audit_log_txt.ftl b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/audit_log_txt.ftl
new file mode 100644
index 0000000..587e366
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/audit_log_txt.ftl
@@ -0,0 +1,42 @@
+<#--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+--------------------------------SUMMARY-----------------------------------
+Users  = ${usersSummary}
+Resources  = ${resourcesSummary}
+
+
+
+
+Users                                             Components/Access
+--------------------------------------------------------------------------
+<#if users??>
+  <#list users as user>
+${user.data}
+  </#list>
+</#if>
+
+
+
+
+
+Resources                                         Components/Access
+--------------------------------------------------------------------------
+<#if resources??>
+  <#list resources as resource>
+${resource.data}
+  </#list>
+</#if>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/service_log_txt.ftl
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/service_log_txt.ftl b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/service_log_txt.ftl
new file mode 100644
index 0000000..8a5e19d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/service_log_txt.ftl
@@ -0,0 +1,36 @@
+<#--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+**********************Summary**********************
+Number of Logs : ${numberOfLogs}
+From           : ${from}
+To             : ${to}
+Host           : ${hosts}
+Component      : ${components}
+Levels         : ${levels}
+Format         : ${format}
+
+Included String: [${iString}]
+
+Excluded String: [${eString}]
+
+************************Logs***********************
+2016-09-26 11:49:19,723 WARN MainThread lock.py:60 - Releasing the lock.
+<#if logs??>
+  <#list logs as log>
+${log.data}
+  </#list>
+</#if>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js
index 08a8271..5fc4bac 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js
@@ -89,7 +89,7 @@ define(['require',
 
       return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
 		},
-		getTruncatedLogs : function(token, options){
+    getTruncatedLogs : function(token, options){
 			var url = Globals.baseURL  + 'service/logs/truncated';
 			
 			options = _.extend({

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js
index 4c23290..6d587cd 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js
@@ -57,7 +57,7 @@ define(['require',
     if (params.bundle_id && !params.start_time && !params.end_time) {
       var collection = new VNameValueList();
 
-      collection.url = Globals.baseURL + "service/logs/solr/boundarydates";
+      collection.url = Globals.baseURL + "service/logs/boundarydates";
       collection.modelAttrName = "vNameValues";
       _.extend(collection.queryParams, {
         "bundle_id": params.bundle_id

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js
index ef6dce5..0822051 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js
@@ -98,7 +98,7 @@ define(['require',
                     pageSize: 9999
                 }
 			});
-			this.topUsers.url = Globals.baseURL + "audit/logs/users";
+			this.topUsers.url = Globals.baseURL + "audit/logs/resources/10";
 			this.topUsers.modelAttrName = "graphData";
 			this.topResources = new VNameValueList([],{
 				state: {
@@ -106,7 +106,7 @@ define(['require',
                     pageSize: 9999
                 }
 			});
-			this.topResources.url = Globals.baseURL + "audit/logs/resources";
+			this.topResources.url = Globals.baseURL + "audit/logs/resources/10";
 			this.topResources.modelAttrName = "graphData";		
 			//initialize colors
 			this.colors = (new d3.scale.category20c().range().slice().reverse()).concat(new d3.scale.category20b().range().slice().reverse());
@@ -408,7 +408,7 @@ define(['require',
 			obj.utcOffset = moment().utcOffset();
 			obj.startIndex =  this.topUsers.state.currentPage * this.topUsers.state.pageSize;
 			var params = $.param(_.extend({},this.topUsers.queryParams,obj));
-			var url = "api/v1/audit/logs/users/export?"+ params;
+			var url = "api/v1/audit/logs/export?"+ params;
 			window.open(url);
 			this.onDialogClosed();
 		}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js
index 0e7f1b8..eb73fb8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js
@@ -62,7 +62,7 @@ define(['require',
 		initialize: function(options) {
 			_.extend(this, _.pick(options,'vent','globalVent','params'));
 			this.logLevelList = new VLogLevelList();
-			this.logLevelList.url = Globals.baseURL + "service/logs/levels/counts/namevalues";
+			this.logLevelList.url = Globals.baseURL + "service/logs/levels/counts";
 			this.logLevelList.modelAttrName = "vNameValues";
 			this.bindEvents();
 		},

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js
index 2c7f0aa..9bdf0fa 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js
@@ -211,10 +211,10 @@ define(['require',
             onEditHost : function(e){
             	var $el = $(e.currentTarget);
             	$el.hide();
-            	if($el.data("type") == "host_name"){
-            		this.showHostSelect2($el.data("component_name"));
+            	if($el.data("type") == "host"){
+            		this.showHostSelect2($el.data("component"));
                 }else{
-            		this.showExpiry($el.data("component_name"));
+            		this.showExpiry($el.data("component"));
                 }
             },
             hideHostSelect2 : function(forComponent){

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
index 43ee5db..298f401 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
@@ -300,6 +300,7 @@ define(['require',
             eventName: Globals.eventName.serviceLogsExcludeColumns,
             myFormatData: function (query, searchCollection) {
               var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedServiceLogMappings, false);
+              console.log(obj)
               return {
                 excludeQuery: JSON.stringify(obj),
                 query: query

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/troubleshoot/TroubleShootLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/troubleshoot/TroubleShootLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/troubleshoot/TroubleShootLayoutView.js
index a6445c6..b19f3ce 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/troubleshoot/TroubleShootLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/troubleshoot/TroubleShootLayoutView.js
@@ -82,7 +82,7 @@ define(['backbone',
 
                     }
                 });
-                this.serviceLogsCollection.url = Globals.baseURL + "service/logs/anygraph";
+                this.serviceLogsCollection.url = Globals.baseURL + "service/logs/count/anygraph";
                 this.serviceLogsCollection.modelAttrName = "graphData";
                 
             	this.topUsers = new VNameValueList([],{
@@ -91,7 +91,7 @@ define(['backbone',
                         pageSize: 9999
                     }
     			});
-    			this.topUsers.url = Globals.baseURL + "audit/logs/users";
+    			this.topUsers.url = Globals.baseURL + "audit/logs/resources/10";
     			this.topUsers.modelAttrName = "graphData";
     			
     			this.serviceLoadCollection = new VLogList([], {
@@ -133,7 +133,7 @@ define(['backbone',
             },
             onRender : function(){
             	var that = this;
-            	this.fetchTopUsers(this.params);
+            	this.fetchTopUsers(_.extend({field : "reqUser"},this.params));
             	this.serviceLogsCollection.getServicesInfo({
                 	success : function(resp){
                 		Globals.servicesInfo = resp;

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/tabs/LogFileView_tmpl.html
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/tabs/LogFileView_tmpl.html b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/tabs/LogFileView_tmpl.html
index f86190c..0f0f143 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/tabs/LogFileView_tmpl.html
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/tabs/LogFileView_tmpl.html
@@ -15,38 +15,6 @@
   limitations under the License.
 -->
 <div class="row">
-	<!--  div class="col-md-3">
-		<div class="row">
-			<div class="col-md-12">
-				<div class="box">
-					<div class="box-header">
-						<div class="box-name">
-							<span>Search</span>
-						</div>
-						<div class="box-icons">
-							<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
-							</a> <a class=""> <i class="fa fa-gear"></i>
-							</a> <a class="close-link"> <i class="fa fa-close"></i>
-							</a>
-						</div>
-						<div class="no-move"></div>
-					</div>
-					<div class="box-content">
-						<div class="input-group">
-							<input data-id="hierarchySearch" type="text" class="form-control"
-								placeholder="Search" value="*:*"> <span
-								class="input-group-btn">
-								<button data-id="hierarchySearchBtn"
-									class="btn btn-default btn-search" type="button">
-									<i class="fa fa-search"></i>
-								</button>
-							</span>
-						</div>
-					</div>
-				</div>
-			</div>
-		</div>
-	</div-->
 	<div class="col-md-12">
 		<div class="row topLevelFilter">
             <div id="r_LogLevel" class="col-md-5"></div>
@@ -54,28 +22,17 @@
             <div id="r_LogSnapShot" class="col-md-1 col-sm-2"></div>
             <div class="row ">
 				<div class="col-md-12 fixedSearchBox hiddeBox">
-					<!-- div id="r_VSSearch"></div-->
 					<div class="col-md-6" data-id="r_vsSearchIncCol"></div>
 					<div class="col-md-6" data-id="r_vsSearchExCol"></div>	
 				</div>
 			</div>
         </div>
         <div class="setHeight_LogFile"></div>
-<!-- 		<div class="row">
-			<div class="col-md-12">
-				<div id="r_LogLevel"></div>
-			</div>
-		</div> -->
 		<div class="row">
 			<div class="col-md-12">
 					<div id="r_Histogram"></div>
 			</div>
 		</div>
-	<!-- 	<div class="row row-margin-bottom">
-			<div class="col-md-12">
-				<div id="r_VSSearch"></div>
-			</div>
-		</div> -->
 		<div class="row">
 			<div class="col-md-12">
 				<div class="box">
@@ -97,17 +54,13 @@
 								<i class="fa fa-sign-out"></i>
 							</a>
 							<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
-							</a> 
-							<!-- <a class="expand-link"> <i class="fa fa-expand"></i></a>
-							<a class="close-link"> <i class="fa fa-close"></i></a> -->
-							
+							</a>
 						</div>
 						<div class="no-move"></div>
 					</div>
 					<div class="box-content">
 						<div class="col-md-4 advance-find">
 							<div class="input-group">
-								<!-- span class="input-group-addon">1 of 40</span -->
 								<span class="input-group-btn">
     							<button data-id="lock" title="Lock position" class="btn btn-default btn-search no-margin" type="button"><i class="fa fa-unlock"></i>
     							</button></span> 
@@ -135,7 +88,6 @@
 									</button>
 									<button data-id="cancelFind" class="btn btn-default btn-search no-margin" style="display:none;">cancel</button>
 									<button style="display:none;" class="no-margin btn-notification pageNotation" type="button"> </button>
-									<!-- <span class="pageNotation"></span> -->
 								</span>
 							</div>
 						</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestQueryConverterTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestQueryConverterTest.java
new file mode 100644
index 0000000..91fe5ca
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestQueryConverterTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.easymock.EasyMockRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.data.solr.core.DefaultQueryParser;
+import org.springframework.data.solr.core.query.SimpleQuery;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RunWith(EasyMockRunner.class)
+public class BaseServiceLogRequestQueryConverterTest {
+
+  private BaseServiceLogRequestQueryConverter underTest;
+
+  private Map<String, String> fieldMap = new HashMap<>();
+
+  private Map<String, String> fieldTypeMap = new HashMap<>();
+
+  @Before
+  public void setUp() {
+    underTest = new BaseServiceLogRequestQueryConverter();
+    fieldMap.put("case_id", "key_lower_case");
+    fieldMap.put("cluster", "key_lower_case");
+    fieldMap.put("bundle_id", "key_lower_case");
+    fieldTypeMap.put("key_lower_case", "{\"name\":\"key_lower_case\",\"class\":\"solr.TextField\",\"sortMissingLast\":true," +
+      "\"omitNorms\":true,\"analyzer\":{\"tokenizer\":{\"class\":\"solr.KeywordTokenizerFactory\"}," +
+      "\"filters\":[{\"class\":\"solr.LowerCaseFilterFactory\"}]}}");
+  }
+
+  @Test
+  public void testConvertRequest() {
+    // GIVEN
+    ServiceLogRequest logRequest = new ServiceLogRequest();
+    logRequest.setLevel("FATAL,ERROR,WARN,UNKNOWN");
+    logRequest.setStartIndex("0");
+    logRequest.setPage("0");
+    //logRequest.setPageSize("25");
+    logRequest.setFrom("2016-09-13T22:00:01.000Z");
+    logRequest.setTo("2016-09-14T22:00:01.000Z");
+    logRequest.setMustBe("logsearch_app,secure_log");
+    logRequest.setMustNot("hst_agent,system_message");
+    logRequest.setFileName("myfile");
+    logRequest.setComponentName("component");
+    logRequest.setHostName("logsearch.com}");
+
+    // WHEN
+    SimpleQuery query = underTest.convert(logRequest);
+    DefaultQueryParser defaultQueryParser = new DefaultQueryParser();
+    SolrQuery solrQuery = defaultQueryParser.doConstructSolrQuery(query);
+    // THEN
+    // TODO extends this test case later
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
index 061c607..eab0c04 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
@@ -64,7 +64,7 @@ public class LoggingRequestHelperImpl implements LoggingRequestHelper {
 
   private static final String LOGSEARCH_QUERY_PATH = "/api/v1/service/logs";
 
-  private static final String LOGSEARCH_GET_LOG_LEVELS_PATH = "/api/v1/service/logs/levels/counts/namevalues";
+  private static final String LOGSEARCH_GET_LOG_LEVELS_PATH = "/api/v1/service/logs/levels/counts";
 
   private static final String LOGSEARCH_ADMIN_CREDENTIAL_NAME = "logsearch.admin.credential";
 


[3/7] ambari git commit: AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
deleted file mode 100644
index d40c5a1..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.springframework.stereotype.Component;
-
-@Component
-public abstract class AbstractCommonAuditLogRequestConverter<SOURCE extends BaseAuditLogRequest, RESULT extends CommonSearchCriteria>
-  extends AbstractCommonSearchRequestConverter<SOURCE, RESULT> {
-
-  @Override
-  public RESULT convertToSearchCriteria(SOURCE request) {
-    RESULT criteria = createCriteria(request);
-    criteria.addParam("q", request.getQuery());
-    criteria.setMustBe(request.getMustBe());
-    criteria.setMustNot(request.getMustNot());
-    criteria.setExcludeQuery(StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
-    criteria.setIncludeQuery(StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
-    criteria.setStartTime(request.getFrom());
-    criteria.setEndTime(request.getTo());
-    return criteria;
-  }
-
-  public abstract RESULT createCriteria(SOURCE request);
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java
deleted file mode 100644
index ea2c28a..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.CommonSearchRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.commons.lang.StringUtils;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_GLOBAL_END_TIME;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_GLOBAL_START_TIME;
-
-public abstract class AbstractCommonSearchRequestConverter<SOURCE extends CommonSearchRequest, RESULT extends CommonSearchCriteria>
-  extends AbstractConverterAware<SOURCE, RESULT> {
-
-  @Override
-  public RESULT convert(SOURCE source) {
-    RESULT criteria = convertToSearchCriteria(source);
-    addDefaultParams(source, criteria);
-    return criteria;
-  }
-
-  public abstract RESULT convertToSearchCriteria(SOURCE source);
-
-  private void addDefaultParams(SOURCE request, RESULT criteria) {
-    criteria.setStartIndex(StringUtils.isNumeric(request.getStartIndex()) ? new Integer(request.getStartIndex()) : 0);
-    criteria.setPage(StringUtils.isNumeric(request.getPage()) ? new Integer(request.getPage()) : 0);
-    criteria.setMaxRows(StringUtils.isNumeric(request.getPageSize()) ? new Integer(request.getPageSize()) : 50);
-    criteria.setSortBy(request.getSortBy());
-    criteria.setSortType(request.getSortType());
-    if (StringUtils.isNotEmpty(request.getStartTime())){
-      criteria.setGlobalStartTime(request.getStartTime());
-      criteria.getUrlParamMap().put(PARAM_GLOBAL_START_TIME, request.getStartTime());
-    }
-    if (StringUtils.isNotEmpty(request.getEndTime())){
-      criteria.setGlobalEndTime(request.getEndTime());
-      criteria.getUrlParamMap().put(PARAM_GLOBAL_END_TIME, request.getEndTime());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
deleted file mode 100644
index 8e91584..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
-import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
-import org.apache.commons.lang.StringEscapeUtils;
-
-public abstract class AbstractCommonServiceLogRequestConverter<SOURCE extends BaseServiceLogRequest, RESULT extends CommonServiceLogSearchCriteria>
-  extends AbstractCommonSearchRequestConverter<SOURCE, RESULT> {
-
-  @Override
-  public RESULT convertToSearchCriteria(SOURCE request) {
-    RESULT criteria = createCriteria(request);
-    // TODO: check are these used from the UI or not?
-    criteria.addParam("q", request.getQuery());
-    criteria.addParam("unselectComp", request.getMustNot());
-
-    criteria.setLevel(request.getLevel());
-    criteria.setFrom(request.getFrom());
-    criteria.setTo(request.getTo());
-    criteria.setSelectComp(request.getMustBe());
-    criteria.setBundleId(request.getBundleId());
-    criteria.setHostName(request.getHostName());
-    criteria.setComponentName(request.getComponentName());
-    criteria.setFileName(request.getFileName());
-    criteria.setStartTime(request.getStartTime());
-    criteria.setEndTime(request.getEndTime());
-    criteria.setExcludeQuery(StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
-    criteria.setIncludeQuery(StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
-    return criteria;
-  }
-
-  public abstract RESULT createCriteria(SOURCE request);
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractConverterAware.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractConverterAware.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractConverterAware.java
index 18a71c1..d8470ea 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractConverterAware.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractConverterAware.java
@@ -18,18 +18,18 @@
  */
 package org.apache.ambari.logsearch.query.converter;
 
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.core.convert.ConversionService;
 import org.springframework.core.convert.converter.Converter;
 import org.springframework.core.convert.converter.ConverterRegistry;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
 public abstract class AbstractConverterAware<SOURCE, RESULT> implements Converter<SOURCE, RESULT> {
 
   @Inject
-  @Qualifier("conversionService")
+  @Named("conversionService")
   private ConversionService conversionService;
 
   public ConversionService getConversionService() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractDateRangeFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractDateRangeFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractDateRangeFacetQueryConverter.java
new file mode 100644
index 0000000..12d19d2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractDateRangeFacetQueryConverter.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
+import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import java.util.Locale;
+
+public abstract class AbstractDateRangeFacetQueryConverter<SOURCE extends DateRangeParamDefinition & UnitParamDefinition>
+  extends AbstractConverterAware<SOURCE , SolrQuery> {
+
+  @Override
+  public SolrQuery convert(SOURCE request) {
+    SolrQuery solrQuery = new SolrQuery();
+    String unit = StringUtils.isBlank(request.getUnit()) ? request.getUnit() : "+1HOUR";
+    solrQuery.setQuery("*:*");
+    solrQuery.setFacet(true);
+    solrQuery.addFacetPivotField("{!range=r1}" + getTypeFieldName());
+    solrQuery.setFacetMinCount(1);
+    solrQuery.setFacetLimit(-1);
+    solrQuery.setFacetSort(LogSearchConstants.FACET_INDEX);
+    solrQuery.add("facet.range", "{!tag=r1}" + getDateFieldName());
+    solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.start"}), request.getFrom());
+    solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.end"}), request.getTo());
+    solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.gap"}), unit);
+    solrQuery.remove("sort");
+    solrQuery.setRows(0);
+    solrQuery.setStart(0);
+    return solrQuery;
+  }
+
+  public abstract String getDateFieldName();
+
+  public abstract String getTypeFieldName();
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractLogRequestFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractLogRequestFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractLogRequestFacetQueryConverter.java
new file mode 100644
index 0000000..17c4e01
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractLogRequestFacetQueryConverter.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+public abstract class AbstractLogRequestFacetQueryConverter<SOURCE extends BaseLogRequest> extends AbstractConverterAware<SOURCE, SimpleFacetQuery>{
+
+  @Override
+  public SimpleFacetQuery convert(SOURCE request) {
+    String fromValue = StringUtils.isNotEmpty(request.getFrom()) ? request.getFrom() : "*";
+    String toValue = StringUtils.isNotEmpty(request.getTo()) ? request.getTo() : "*";
+    Criteria criteria = new SimpleStringCriteria("*:*");
+    SimpleFacetQuery facetQuery = new SimpleFacetQuery();
+    facetQuery.addCriteria(criteria);
+    SimpleFilterQuery simpleFilterQuery = new SimpleFilterQuery();
+    simpleFilterQuery.addCriteria(new SimpleStringCriteria(getDateTimeField() + ":[" + fromValue +" TO "+ toValue+ "]" ));
+    facetQuery.addFilterQuery(simpleFilterQuery);
+    FacetOptions facetOptions = new FacetOptions();
+    facetOptions.setFacetMinCount(1);
+    facetOptions.setFacetSort(getFacetSort());
+    appendFacetOptions(facetOptions, request);
+    facetQuery.setFacetOptions(facetOptions);
+    facetQuery.setRows(0);
+    appendFacetQuery(facetQuery, request);
+    return facetQuery;
+  }
+
+  public abstract FacetOptions.FacetSort getFacetSort();
+
+  public abstract String getDateTimeField();
+
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, SOURCE request) {
+  }
+
+  public void appendFacetOptions(FacetOptions facetOptions, SOURCE request) {
+    facetOptions.setFacetLimit(-1);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractLogRequestQueryConverter.java
new file mode 100644
index 0000000..a4ca73d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractLogRequestQueryConverter.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.springframework.data.solr.core.query.Query;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+
+public abstract class AbstractLogRequestQueryConverter<REQUEST_TYPE extends BaseLogRequest, QUERY_TYPE extends Query>
+  extends AbstractSearchRequestQueryConverter<REQUEST_TYPE, QUERY_TYPE> {
+
+  @Override
+  public QUERY_TYPE extendSolrQuery(REQUEST_TYPE request, QUERY_TYPE query) {
+    List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
+    List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
+    addInFilterQuery(query, COMPONENT, includeTypes);
+    addInFilterQuery(query, COMPONENT, excludeTypes, true);
+    addIncludeFieldValues(query, StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
+    addExcludeFieldValues(query, StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
+    return extendLogQuery(request, query);
+  }
+
+  public abstract QUERY_TYPE extendLogQuery(REQUEST_TYPE request, QUERY_TYPE query);
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractSearchRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractSearchRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractSearchRequestQueryConverter.java
new file mode 100644
index 0000000..b8e351c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractSearchRequestQueryConverter.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import com.google.common.base.Splitter;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
+import org.apache.ambari.logsearch.model.request.impl.CommonSearchRequest;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.Query;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOG_MESSAGE;
+
+public abstract class AbstractSearchRequestQueryConverter<REQUEST_TYPE extends CommonSearchRequest, QUERY_TYPE extends Query>
+  extends AbstractConverterAware<REQUEST_TYPE, QUERY_TYPE> {
+
+  @Inject
+  @Named("serviceSolrFieldDao")
+  private SolrSchemaFieldDao serviceSolrSchemaFieldDao;
+
+  @Inject
+  @Named("auditSolrFieldDao")
+  private SolrSchemaFieldDao auditSolrSchemaFieldDao;
+
+  @Override
+  public QUERY_TYPE convert(REQUEST_TYPE request) {
+    QUERY_TYPE query = createQuery();
+    int page = StringUtils.isNumeric(request.getPage()) ? new Integer(request.getPage()) : 0;
+    int pageSize = StringUtils.isNumeric(request.getPageSize()) ? new Integer(request.getPageSize()) : Integer.MAX_VALUE;
+    PageRequest pageRequest = new PageRequest(page, pageSize, sort(request));
+    query.setPageRequest(pageRequest);
+    Criteria criteria = new SimpleStringCriteria("*:*");
+    query.addCriteria(criteria);
+    return extendSolrQuery(request, query);
+  }
+
+  public abstract QUERY_TYPE extendSolrQuery(REQUEST_TYPE request, QUERY_TYPE query);
+
+  public abstract Sort sort(REQUEST_TYPE request);
+
+  public abstract QUERY_TYPE createQuery();
+
+  public abstract LogType getLogType();
+
+  public List<String> splitValueAsList(String value, String separator) {
+    return StringUtils.isNotEmpty(value) ? Splitter.on(separator).omitEmptyStrings().splitToList(value) : null;
+  }
+
+  public Query addEqualsFilterQuery(Query query, String field, String value) {
+    return this.addEqualsFilterQuery(query, field, value, false);
+  }
+
+  public Query addEqualsFilterQuery(Query query, String field, String value, boolean negate) {
+    if (StringUtils.isNotEmpty(value)) {
+      addFilterQuery(query, new Criteria(field).is(value), negate);
+    }
+    return query;
+  }
+
+  public Query addContainsFilterQuery(Query query, String field, String value) {
+    return this.addContainsFilterQuery(query, field, value, false);
+  }
+
+  public Query addContainsFilterQuery(Query query, String field, String value, boolean negate) {
+    if (StringUtils.isNotEmpty(value)) {
+      addFilterQuery(query, new Criteria(field).contains(value), negate);
+    }
+    return query;
+  }
+
+  public Query addInFilterQuery(Query query, String field, List<String> values) {
+    return this.addInFilterQuery(query, field, values, false);
+  }
+
+  public Query addInFilterQuery(Query query, String field, List<String> values, boolean negate) {
+    if (CollectionUtils.isNotEmpty(values)) {
+      addFilterQuery(query, new Criteria(field).is(values), negate);
+    }
+    return query;
+  }
+
+  public Query addRangeFilter(Query query, String field, String from, String to) {
+    return this.addRangeFilter(query, field, from, to, false);
+  }
+
+  public Query addRangeFilter(Query query, String field, String from, String to, boolean negate) { // TODO use criteria.between without escaping
+    String fromValue = StringUtils.isNotEmpty(from) ? from : "*";
+    String toValue = StringUtils.isNotEmpty(to) ? to : "*";
+    addFilterQuery(query, new SimpleStringCriteria(field + ":[" + fromValue +" TO "+ toValue + "]" ), negate);
+    return query;
+  }
+
+  public Query addIncludeFieldValues(Query query, String fieldValuesMapStr) {
+    if (StringUtils.isNotEmpty(fieldValuesMapStr)) {
+      List<Map<String, String>> criterias = new Gson().fromJson(fieldValuesMapStr,
+        new TypeToken<List<HashMap<String, String>>>(){}.getType());
+      for (Map<String, String> criteriaMap : criterias) {
+        for (Map.Entry<String, String> fieldEntry : criteriaMap.entrySet()) {
+          escapeFieldValueByType(fieldEntry);
+          addFilterQuery(query, new Criteria(fieldEntry.getKey()).is(escapeFieldValueByType(fieldEntry)), false);
+        }
+      }
+    }
+    return query;
+  }
+
+  public Query addExcludeFieldValues(Query query, String fieldValuesMapStr) {
+    if (StringUtils.isNotEmpty(fieldValuesMapStr)) {
+      List<Map<String, String>> criterias = new Gson().fromJson(fieldValuesMapStr,
+        new TypeToken<List<HashMap<String, String>>>(){}.getType());
+      for (Map<String, String> criteriaMap : criterias) {
+        for (Map.Entry<String, String> fieldEntry : criteriaMap.entrySet()) {
+          addFilterQuery(query, new Criteria(fieldEntry.getKey()).is(escapeFieldValueByType(fieldEntry)), true);
+        }
+      }
+    }
+    return query;
+  }
+
+  private String escapeFieldValueByType(Map.Entry<String, String> fieldEntry) {
+    String escapedFieldValue;
+    if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
+      escapedFieldValue = SolrUtil.escapeForLogMessage(fieldEntry.getValue());
+    } else {
+      escapedFieldValue = SolrUtil.putWildCardByType(fieldEntry.getValue(), fieldEntry.getKey(), getSchemaFieldsTypeMapByLogType(getLogType()));
+    }
+    return escapedFieldValue;
+  }
+
+  private void addFilterQuery(Query query, Criteria criteria, boolean negate) {
+    if (negate) {
+      criteria.not();
+    }
+    query.addFilterQuery(new SimpleFilterQuery(criteria));
+  }
+
+  private Map<String, String> getSchemaFieldsTypeMapByLogType(LogType logType) {
+    return LogType.AUDIT.equals(logType) ? auditSolrSchemaFieldDao.getSchemaFieldTypeMap() : serviceSolrSchemaFieldDao.getSchemaFieldTypeMap();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java
deleted file mode 100644
index 1639563..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.AnyGraphRequest;
-import org.apache.ambari.logsearch.query.model.AnyGraphSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AnyGraphRequestConverter extends AbstractCommonSearchRequestConverter<AnyGraphRequest, AnyGraphSearchCriteria> {
-
-  @Override
-  public AnyGraphSearchCriteria convertToSearchCriteria(AnyGraphRequest anyGraphRequest) {
-    AnyGraphSearchCriteria criteria = new AnyGraphSearchCriteria();
-    criteria.setxAxis(anyGraphRequest.getxAxis());
-    criteria.setyAxis(anyGraphRequest.getyAxis());
-    criteria.setStackBy(anyGraphRequest.getStackBy());
-    criteria.setUnit(anyGraphRequest.getUnit());
-    criteria.setFrom(anyGraphRequest.getFrom());
-    criteria.setTo(anyGraphRequest.getTo());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.java
deleted file mode 100644
index ac74287..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
-import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AuditBarGraphRequestConverter extends AbstractCommonAuditLogRequestConverter<AuditBarGraphRequest, AuditBarGraphSearchCriteria>{
-
-  @Override
-  public AuditBarGraphSearchCriteria createCriteria(AuditBarGraphRequest request) {
-    AuditBarGraphSearchCriteria criteria = new AuditBarGraphSearchCriteria();
-    criteria.setUnit(request.getUnit());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestQueryConverter.java
new file mode 100644
index 0000000..eca88c2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestQueryConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+
+@Named
+public class AuditBarGraphRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<AuditBarGraphRequest> {
+
+  @Override
+  public String getDateFieldName() {
+    return AUDIT_EVTTIME;
+  }
+
+  @Override
+  public String getTypeFieldName() {
+    return AUDIT_COMPONENT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditComponentsRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditComponentsRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditComponentsRequestQueryConverter.java
new file mode 100644
index 0000000..645c0c3
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditComponentsRequestQueryConverter.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class AuditComponentsRequestQueryConverter extends AbstractSearchRequestQueryConverter<AuditComponentRequest, SimpleFacetQuery> {
+
+  @Override
+  public SimpleFacetQuery extendSolrQuery(AuditComponentRequest request, SimpleFacetQuery query) {
+    FacetOptions facetOptions = new FacetOptions();
+    facetOptions.addFacetOnField(AUDIT_COMPONENT);
+    facetOptions.setFacetSort(FacetOptions.FacetSort.INDEX);
+    facetOptions.setFacetLimit(-1);
+    query.setFacetOptions(facetOptions);
+    return query;
+  }
+
+  @Override
+  public Sort sort(AuditComponentRequest request) {
+    Sort.Direction direction = StringUtils.equals(request.getSortType(), LogSearchConstants.DESCENDING_ORDER)
+      ? Sort.Direction.DESC : Sort.Direction.ASC;
+    return new Sort(new Sort.Order(direction, AUDIT_COMPONENT));
+  }
+
+  @Override
+  public SimpleFacetQuery createQuery() {
+    return new SimpleFacetQuery();
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.AUDIT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.java
deleted file mode 100644
index 5ec7632..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
-import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<AuditLogRequest, AuditLogSearchCriteria> {
-
-  @Override
-  public AuditLogSearchCriteria createCriteria(AuditLogRequest request) {
-    AuditLogSearchCriteria criteria = new AuditLogSearchCriteria();
-    criteria.setLastPage(request.isLastPage());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestQueryConverter.java
new file mode 100644
index 0000000..317b1fa
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestQueryConverter.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
+import org.springframework.data.solr.core.query.SimpleQuery;
+
+import javax.inject.Named;
+
+@Named
+public class AuditLogRequestQueryConverter extends AbstractAuditLogRequestQueryConverter<AuditLogRequest, SimpleQuery> {
+
+  @Override
+  public SimpleQuery extendLogQuery(AuditLogRequest request, SimpleQuery query) {
+    return query;
+  }
+
+  @Override
+  public SimpleQuery createQuery() {
+    return new SimpleQuery();
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.AUDIT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditServiceLoadRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditServiceLoadRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditServiceLoadRequestQueryConverter.java
new file mode 100644
index 0000000..1008191
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditServiceLoadRequestQueryConverter.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class AuditServiceLoadRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<AuditServiceLoadRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return AUDIT_EVTTIME;
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, AuditServiceLoadRequest request) {
+    facetOptions.addFacetOnField(AUDIT_COMPONENT);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java
deleted file mode 100644
index 35aceb2..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class BaseAuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<BaseAuditLogRequest, CommonSearchCriteria> {
-
-  @Override
-  public CommonSearchCriteria createCriteria(BaseAuditLogRequest request) {
-    return new CommonSearchCriteria();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java
deleted file mode 100644
index efc9bc9..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class BaseServiceLogRequestConverter extends AbstractCommonServiceLogRequestConverter<BaseServiceLogRequest, CommonServiceLogSearchCriteria> {
-
-  @Override
-  public CommonServiceLogSearchCriteria createCriteria(BaseServiceLogRequest request) {
-    return new CommonServiceLogSearchCriteria();
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestQueryConverter.java
new file mode 100644
index 0000000..1d86844
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestQueryConverter.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.SimpleQuery;
+import javax.inject.Named;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.KEY_LOG_MESSAGE;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.PATH;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.BUNDLE_ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+
+@Named
+public class BaseServiceLogRequestQueryConverter extends AbstractLogRequestQueryConverter<BaseServiceLogRequest, SimpleQuery> {
+
+  @Override
+  public SimpleQuery extendLogQuery(BaseServiceLogRequest request, SimpleQuery query) {
+    List<String> levels = splitValueAsList(request.getLevel(), ",");
+    addContainsFilterQuery(query, KEY_LOG_MESSAGE, SolrUtil.escapeForStandardTokenizer(request.getiMessage()));
+    addContainsFilterQuery(query, KEY_LOG_MESSAGE, SolrUtil.escapeForStandardTokenizer(request.geteMessage()), true);
+    addEqualsFilterQuery(query, HOST, SolrUtil.escapeQueryChars(request.getHostName()));
+    addEqualsFilterQuery(query, PATH, SolrUtil.escapeQueryChars(request.getFileName()));
+    addEqualsFilterQuery(query, COMPONENT, SolrUtil.escapeQueryChars(request.getComponentName()));
+    addEqualsFilterQuery(query, BUNDLE_ID, request.getBundleId());
+    addInFilterQuery(query, LEVEL, levels);
+    addRangeFilter(query, LOGTIME, request.getFrom(), request.getTo());
+    return query;
+  }
+
+  @Override
+  public Sort sort(BaseServiceLogRequest request) {
+    String sortBy = request.getSortBy();
+    String sortType = request.getSortType();
+    Sort.Order defaultSortOrder;
+    if (!StringUtils.isBlank(sortBy)) {
+      Sort.Direction direction = StringUtils.equals(sortType, LogSearchConstants.ASCENDING_ORDER) ? Sort.Direction.ASC : Sort.Direction.DESC;
+      defaultSortOrder = new Sort.Order(direction, sortBy);
+    } else {
+      defaultSortOrder = new Sort.Order(Sort.Direction.DESC, LOGTIME);
+    }
+    Sort.Order secuqnceIdOrder = new Sort.Order(Sort.Direction.DESC, SEQUENCE_ID);
+    return new Sort(defaultSortOrder, secuqnceIdOrder);
+  }
+
+  @Override
+  public SimpleQuery createQuery() {
+    return new SimpleQuery();
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java
deleted file mode 100644
index 6197d48..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
-import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class FieldAuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<FieldAuditLogRequest, FieldAuditLogSearchCriteria> {
-
-  @Override
-  public FieldAuditLogSearchCriteria createCriteria(FieldAuditLogRequest request) {
-    FieldAuditLogSearchCriteria criteria = new FieldAuditLogSearchCriteria();
-    criteria.setField(request.getField());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestQueryConverter.java
new file mode 100644
index 0000000..02c1557
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestQueryConverter.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class FieldAuditLogRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<FieldAuditLogRequest> {
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, FieldAuditLogRequest request) {
+    facetOptions.addFacetOnPivot(request.getField(), AUDIT_COMPONENT);
+    facetOptions.setFacetLimit(request.getTop());
+  }
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return AUDIT_EVTTIME;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java
deleted file mode 100644
index 74b0dac..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.FieldAuditBarGraphRequest;
-import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class FieldBarGraphRequestConverter extends AbstractCommonAuditLogRequestConverter<FieldAuditBarGraphRequest, FieldAuditBarGraphSearchCriteria> {
-
-  @Override
-  public FieldAuditBarGraphSearchCriteria createCriteria(FieldAuditBarGraphRequest request) {
-    FieldAuditBarGraphSearchCriteria criteria = new FieldAuditBarGraphSearchCriteria();
-    criteria.setUnit(request.getUnit());
-    criteria.setField(request.getField());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.java
deleted file mode 100644
index 8f1aaf0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
-import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceAnyGraphRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceAnyGraphRequest, ServiceAnyGraphSearchCriteria> {
-
-  @Override
-  public ServiceAnyGraphSearchCriteria createCriteria(ServiceAnyGraphRequest anyGraphRequest) {
-    ServiceAnyGraphSearchCriteria criteria = new ServiceAnyGraphSearchCriteria();
-    criteria.setxAxis(anyGraphRequest.getxAxis());
-    criteria.setyAxis(anyGraphRequest.getyAxis());
-    criteria.setStackBy(anyGraphRequest.getStackBy());
-    criteria.setUnit(anyGraphRequest.getUnit());
-    criteria.setFrom(anyGraphRequest.getFrom());
-    criteria.setTo(anyGraphRequest.getTo());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java
deleted file mode 100644
index 489e879..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceExtremeDatesRequest;
-import org.apache.ambari.logsearch.query.model.ServiceExtremeDatesCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceExtremeDatesRequestConverter extends AbstractCommonSearchRequestConverter<ServiceExtremeDatesRequest, ServiceExtremeDatesCriteria> {
-
-  @Override
-  public ServiceExtremeDatesCriteria convertToSearchCriteria(ServiceExtremeDatesRequest request) {
-    ServiceExtremeDatesCriteria criteria = new ServiceExtremeDatesCriteria();
-    criteria.setBundleId(request.getBundleId());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
deleted file mode 100644
index 37ec7dc..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
-import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceGraphRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceGraphRequest, ServiceGraphSearchCriteria> {
-
-  @Override
-  public ServiceGraphSearchCriteria createCriteria(ServiceGraphRequest request) {
-    ServiceGraphSearchCriteria criteria = new ServiceGraphSearchCriteria();
-    criteria.setUnit(request.getUnit());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogAnyGraphRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogAnyGraphRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogAnyGraphRequestQueryConverter.java
new file mode 100644
index 0000000..4c549a0
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogAnyGraphRequestQueryConverter.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+
+import javax.inject.Named;
+
+@Named
+public class ServiceLogAnyGraphRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceAnyGraphRequest>{
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceAnyGraphRequest request) {
+    facetOptions.addFacetOnField(LEVEL);
+  }
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogComponentLevelRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogComponentLevelRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogComponentLevelRequestQueryConverter.java
new file mode 100644
index 0000000..0154128
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogComponentLevelRequestQueryConverter.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentLevelRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogComponentLevelRequestQueryConverter extends AbstractLogRequestFacetQueryConverter <ServiceLogComponentLevelRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogComponentLevelRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogComponentLevelRequest request) {
+    facetOptions.addFacetOnPivot(COMPONENT, LEVEL);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogComponentRequestFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogComponentRequestFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogComponentRequestFacetQueryConverter.java
new file mode 100644
index 0000000..6aa8e2d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogComponentRequestFacetQueryConverter.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentHostRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogComponentRequestFacetQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogComponentHostRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogComponentHostRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogComponentHostRequest request) {
+    facetOptions.addFacetOnPivot(COMPONENT, HOST, LEVEL);
+    facetOptions.addFacetOnPivot(COMPONENT, LEVEL);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
deleted file mode 100644
index 783b0e0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest;
-import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceLogExportRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogExportRequest, ServiceLogExportSearchCriteria> {
-
-  @Override
-  public ServiceLogExportSearchCriteria createCriteria(ServiceLogExportRequest request) {
-    ServiceLogExportSearchCriteria criteria = new ServiceLogExportSearchCriteria();
-    criteria.setFormat(request.getFormat());
-    criteria.setUtcOffset(request.getUtcOffset());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogLevelCountRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogLevelCountRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogLevelCountRequestQueryConverter.java
new file mode 100644
index 0000000..30cb05b
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogLevelCountRequestQueryConverter.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogLevelCountRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+
+@Named
+public class ServiceLogLevelCountRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogLevelCountRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogLevelCountRequest request) {
+    facetOptions.addFacetOnField(LEVEL);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogLevelDateRangeRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogLevelDateRangeRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogLevelDateRangeRequestQueryConverter.java
new file mode 100644
index 0000000..2b7a521
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogLevelDateRangeRequestQueryConverter.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import javax.inject.Named;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogLevelDateRangeRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<ServiceGraphRequest>{
+
+  @Override
+  public String getDateFieldName() {
+    return LOGTIME;
+  }
+
+  @Override
+  public String getTypeFieldName() {
+    return LEVEL;
+  }
+
+  @Override
+  public SolrQuery convert(ServiceGraphRequest request) {
+    SolrQuery solrQuery = super.convert(request);
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+    if (!levels.isEmpty()) {
+      solrQuery.addFilterQuery(String.format("%s:(%s)", LEVEL, StringUtils.join(levels, " OR ")));
+    }
+    return solrQuery;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
deleted file mode 100644
index 86d055d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest;
-import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceLogRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogRequest, ServiceLogSearchCriteria> {
-
-  @Override
-  public ServiceLogSearchCriteria createCriteria(ServiceLogRequest request) {
-    ServiceLogSearchCriteria criteria = new ServiceLogSearchCriteria();
-    criteria.setKeyword(StringEscapeUtils.unescapeXml(request.getKeyWord()));
-    criteria.setKeywordType(request.getKeywordType());
-    criteria.setSourceLogId(request.getSourceLogId());
-    criteria.setToken(request.getToken());
-    criteria.setLastPage(request.isLastPage());
-    return criteria;
-  }
-}


[4/7] ambari git commit: AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
index 6772138..840d9bd 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
@@ -27,7 +27,6 @@ import java.util.List;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.MessageEnums;
 import org.apache.ambari.logsearch.dao.UserConfigSolrDao;
-import org.apache.ambari.logsearch.query.QueryGeneration;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.ambari.logsearch.util.SolrUtil;
@@ -45,18 +44,16 @@ import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
+@Named
 public class UserConfigManager extends JsonManagerBase {
 
   private static final Logger logger = Logger.getLogger(UserConfigManager.class);
   @Inject
   private UserConfigSolrDao userConfigSolrDao;
-  @Inject
-  private QueryGeneration queryGenerator;
 
   public String saveUserConfig(VUserConfig vHistory) {
 
@@ -82,9 +79,9 @@ public class UserConfigManager extends JsonManagerBase {
     }
     // Check whether the Filter Name exists in solr
     SolrQuery solrQuery = new SolrQuery();
-    SolrUtil.setMainQuery(solrQuery, null);
-    queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName));
-    queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.USER_NAME, loggedInUserName);
+    solrQuery.setQuery("*:*");
+    solrQuery.addFilterQuery(String.format("%s:%s", LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
+    solrQuery.addFilterQuery(String.format("%s:%s", LogSearchConstants.USER_NAME, loggedInUserName));
     try {
       QueryResponse queryResponse = userConfigSolrDao.process(solrQuery);
       if (queryResponse != null) {
@@ -94,7 +91,7 @@ public class UserConfigManager extends JsonManagerBase {
           throw RESTErrorUtil.createRESTException("Filtername is already present", MessageEnums.INVALID_INPUT_DATA);
         }
       }
-    } catch (SolrException | SolrServerException | IOException e) {
+    } catch (SolrException e) {
       logger.error("Error in checking same filtername config", e);
       throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
@@ -122,7 +119,7 @@ public class UserConfigManager extends JsonManagerBase {
         if (numFound > 0) {
           return true;
         }
-      } catch (SolrException | SolrServerException | IOException e) {
+      } catch (SolrException e) {
         logger.error("Error while checking if userConfig is unique.", e);
       }
     }
@@ -163,13 +160,12 @@ public class UserConfigManager extends JsonManagerBase {
     filterName = StringUtils.isBlank(filterName) ? "*" : "*" + filterName + "*";
 
     try {
-
       SolrQuery userConfigQuery = new SolrQuery();
-      SolrUtil.setMainQuery(userConfigQuery, null);
-      queryGenerator.setPagination(userConfigQuery, searchCriteria);
-      queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.ROW_TYPE, rowType);
-      queryGenerator.setSingleORFilter(userConfigQuery, LogSearchConstants.USER_NAME, userName, LogSearchConstants.SHARE_NAME_LIST, userName);
-      queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName));
+      userConfigQuery.setQuery("*:*");
+      setPagination(userConfigQuery, searchCriteria);
+      userConfigQuery.addFilterQuery(String.format("%s:%s", LogSearchConstants.ROW_TYPE, rowType));
+      userConfigQuery.addFilterQuery(String.format("%s:%s OR %s:%s", LogSearchConstants.USER_NAME, userName, LogSearchConstants.SHARE_NAME_LIST, userName));
+      userConfigQuery.addFilterQuery(String.format("%s:%s", LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
 
       if (StringUtils.isBlank(searchCriteria.getSortBy())) {
         searchCriteria.setSortBy(LogSearchConstants.FILTER_NAME);
@@ -178,7 +174,7 @@ public class UserConfigManager extends JsonManagerBase {
         searchCriteria.setSortType("" + SolrQuery.ORDER.asc);
       }
 
-      queryGenerator.setSingleSortOrder(userConfigQuery, searchCriteria);
+      setSingleSortOrder(userConfigQuery, searchCriteria);
       solrList = userConfigSolrDao.process(userConfigQuery).getResults();
 
       Collection<VUserConfig> configList = new ArrayList<VUserConfig>();
@@ -208,7 +204,7 @@ public class UserConfigManager extends JsonManagerBase {
       userConfigList.setPageSize((int) searchCriteria.getMaxRows());
 
       userConfigList.setTotalCount((long) solrList.getNumFound());
-    } catch (SolrException | SolrServerException | IOException e) {
+    } catch (SolrException e) {
       // do nothing
       logger.error(e);
       throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
@@ -255,7 +251,7 @@ public class UserConfigManager extends JsonManagerBase {
     List<String> userList = new ArrayList<String>();
     try {
       SolrQuery userListQuery = new SolrQuery();
-      SolrUtil.setMainQuery(userListQuery, null);
+      userListQuery.setQuery("*:*");
       SolrUtil.setFacetField(userListQuery, LogSearchConstants.USER_NAME);
       QueryResponse queryResponse = userConfigSolrDao.process(userListQuery);
       if (queryResponse == null) {
@@ -266,10 +262,44 @@ public class UserConfigManager extends JsonManagerBase {
         String userName = cnt.getName();
         userList.add(userName);
       }
-    } catch (SolrException | SolrServerException | IOException e) {
+    } catch (SolrException e) {
       logger.warn("Error getting all users.", e);
       throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
     return convertObjToString(userList);
   }
+
+  private void setSingleSortOrder(SolrQuery solrQuery, SearchCriteria searchCriteria) {
+    List<SolrQuery.SortClause> sort = new ArrayList<>();
+    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
+      SolrQuery.ORDER order = SolrQuery.ORDER.asc;
+      if (!order.toString().equalsIgnoreCase(searchCriteria.getSortType())) {
+        order = SolrQuery.ORDER.desc;
+      }
+      SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(searchCriteria.getSortBy(), order);
+      sort.add(sortOrder);
+      solrQuery.setSorts(sort);
+      logger.debug("Sort Order :-" + sort);
+    }
+  }
+
+  private void setPagination(SolrQuery solrQuery, SearchCriteria searchCriteria) {
+    Integer startIndex = null;
+    Integer maxRows = null;
+    try {
+      startIndex = (Integer) searchCriteria.getStartIndex();
+      SolrUtil.setStart(solrQuery, startIndex);
+    } catch (ClassCastException e) {
+      SolrUtil.setStart(solrQuery, 0);
+    }
+    try {
+      maxRows = (Integer) searchCriteria.getMaxRows();
+      SolrUtil.setRowCount(solrQuery, maxRows);
+    } catch (ClassCastException e) {
+      SolrUtil.setRowCount(solrQuery, 10);
+    }
+
+    if (startIndex != null && maxRows != null)
+      logger.info("Pagination was set from " + startIndex.intValue() + " to " + maxRows.intValue());
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
index e44de35..4840eaa 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
@@ -20,6 +20,8 @@ package org.apache.ambari.logsearch.model.request;
 
 import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.E_MESSAGE_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.I_MESSAGE_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.MUST_BE_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.MUST_NOT_D;
@@ -33,6 +35,11 @@ public interface LogParamDefinition {
   @ApiParam(value = I_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_I_MESSAGE)
   void setiMessage(String iMessage);
 
+  String geteMessage();
+
+  @ApiParam(value = E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
+  void seteMessage(String eMessage);
+
   String getMustBe();
 
   @ApiParam(value = MUST_BE_D, name = LogSearchConstants.REQUEST_PARAM_MUST_BE)

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java
index c3e2998..d3832c1 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java
@@ -37,8 +37,8 @@ public interface LogTruncatedParamDefinition {
   @ApiParam(value = SCROLL_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_SCROLL_TYPE)
   void setScrollType(String scrollType);
 
-  String getNumberRows();
+  Integer getNumberRows();
 
   @ApiParam(value = NUMBER_ROWS_D, name = LogSearchConstants.REQUEST_PARAM_NUMBER_ROWS)
-  void setNumberRows(String numberRows);
+  void setNumberRows(Integer numberRows);
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java
deleted file mode 100644
index 3fcdbc0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.QUERY_D;
-
-public interface QueryParamDefinition {
-
-  String getQuery();
-
-  @ApiParam(value = QUERY_D, name = LogSearchConstants.REQUEST_PARAM_QUERY)
-  void setQuery(String query);
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
index abc1f08..1783a8d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
@@ -22,12 +22,9 @@ import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.LEVEL_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.E_MESSAGE_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.G_MUST_NOT_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.HOST_NAME_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.COMPONENT_NAME_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.FILE_NAME_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.DATE_RANGE_LABEL_D;
 
 public interface ServiceLogParamDefinition {
 
@@ -36,11 +33,6 @@ public interface ServiceLogParamDefinition {
   @ApiParam(value = LEVEL_D, name = LogSearchConstants.REQUEST_PARAM_LEVEL)
   void setLevel(String level);
 
-  String geteMessage();
-
-  @ApiParam(value = E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
-  void seteMessage(String eMessage);
-
   String getHostName();
 
   @ApiParam(value = HOST_NAME_D, name = LogSearchConstants.REQUEST_PARAM_HOST_NAME)
@@ -55,9 +47,4 @@ public interface ServiceLogParamDefinition {
 
   @ApiParam(value = FILE_NAME_D, name = LogSearchConstants.REQUEST_PARAM_FILE_NAME)
   void setFileName(String fileName);
-
-  String getDateRangeLabel();
-
-  @ApiParam(value = DATE_RANGE_LABEL_D, name = LogSearchConstants.REQUEST_PARAM_DATE_RANGE_LABEL)
-  void setDateRangeLabel(String dateRangeLabel);
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java
new file mode 100644
index 0000000..97d9543
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.TOP;
+
+public interface TopParamDefinition {
+  Integer getTop();
+
+  @ApiParam(value = TOP, name = LogSearchConstants.REQUEST_PARAM_TOP, required = true)
+  void setTop(Integer top);
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java
deleted file mode 100644
index 41da712..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request.impl;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.AnyGraphParamDefinition;
-import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
-import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class AnyGraphRequest extends CommonSearchRequest
-  implements AnyGraphParamDefinition, DateRangeParamDefinition, UnitParamDefinition{
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_XAXIS)
-  private String xAxis;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_YAXIS)
-  private String yAxis;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_STACK_BY)
-  private String stackBy;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
-  private String from;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
-  private String to;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
-  private String unit;
-
-  @Override
-  public String getxAxis() {
-    return xAxis;
-  }
-
-  @Override
-  public void setxAxis(String xAxis) {
-    this.xAxis = xAxis;
-  }
-
-  @Override
-  public String getyAxis() {
-    return yAxis;
-  }
-
-  @Override
-  public void setyAxis(String yAxis) {
-    this.yAxis = yAxis;
-  }
-
-  @Override
-  public String getStackBy() {
-    return stackBy;
-  }
-
-  @Override
-  public void setStackBy(String stackBy) {
-    this.stackBy = stackBy;
-  }
-
-  @Override
-  public String getFrom() {
-    return from;
-  }
-
-  @Override
-  public void setFrom(String from) {
-    this.from = from;
-  }
-
-  @Override
-  public String getTo() {
-    return to;
-  }
-
-  @Override
-  public void setTo(String to) {
-    this.to = to;
-  }
-
-  @Override
-  public String getUnit() {
-    return unit;
-  }
-
-  @Override
-  public void setUnit(String unit) {
-    this.unit = unit;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java
index 91e7d1e..03ca32d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java
@@ -23,7 +23,7 @@ import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
 
 import javax.ws.rs.QueryParam;
 
-public class AuditBarGraphRequest extends BaseAuditLogRequest implements UnitParamDefinition {
+public class AuditBarGraphRequest extends BaseLogRequest implements UnitParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
   private String unit;

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditComponentRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditComponentRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditComponentRequest.java
new file mode 100644
index 0000000..94cb255
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditComponentRequest.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class AuditComponentRequest extends CommonSearchRequest {
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java
index 8dd13dc..36fa378 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java
@@ -23,7 +23,7 @@ import org.apache.ambari.logsearch.model.request.LastPageParamDefinition;
 
 import javax.ws.rs.QueryParam;
 
-public class AuditLogRequest extends BaseAuditLogRequest implements LastPageParamDefinition {
+public class AuditLogRequest extends BaseLogRequest implements LastPageParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_LAST_PAGE)
   private boolean isLastPage;

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditServiceLoadRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditServiceLoadRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditServiceLoadRequest.java
new file mode 100644
index 0000000..64ee2d2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditServiceLoadRequest.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class AuditServiceLoadRequest extends BaseLogRequest {
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.java
deleted file mode 100644
index 74b4ab7..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request.impl;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class BaseAuditLogRequest extends BaseLogRequest implements DateRangeParamDefinition {
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
-  private String from;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
-  private String to;
-
-  @Override
-  public String getFrom() {
-    return from;
-  }
-
-  @Override
-  public void setFrom(String from) {
-    this.from = from;
-  }
-
-  @Override
-  public String getTo() {
-    return to;
-  }
-
-  @Override
-  public void setTo(String to) {
-    this.to = to;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
index 1371350..3b6bdd6 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
@@ -18,17 +18,20 @@
  */
 package org.apache.ambari.logsearch.model.request.impl;
 
-import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
 import org.apache.ambari.logsearch.model.request.LogParamDefinition;
 
 import javax.ws.rs.QueryParam;
 
-public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
+public class BaseLogRequest extends CommonSearchRequest implements LogParamDefinition, DateRangeParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_I_MESSAGE)
   private String iMessage;
 
+  @QueryParam(LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
+  private String eMessage;
+
   @QueryParam(LogSearchConstants.REQUEST_PARAM_MUST_BE)
   private String mustBe;
 
@@ -41,6 +44,12 @@ public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
   @QueryParam(LogSearchConstants.REQUEST_PARAM_INCLUDE_QUERY)
   private String includeQuery;
 
+  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
+  private String from;
+
+  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
+  private String to;
+
   @Override
   public String getiMessage() {
     return iMessage;
@@ -52,6 +61,16 @@ public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
   }
 
   @Override
+  public String geteMessage() {
+    return eMessage;
+  }
+
+  @Override
+  public void seteMessage(String eMessage) {
+    this.eMessage = eMessage;
+  }
+
+  @Override
   public String getMustBe() {
     return mustBe;
   }
@@ -90,4 +109,24 @@ public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
   public void setExcludeQuery(String excludeQuery) {
     this.excludeQuery = excludeQuery;
   }
+
+  @Override
+  public String getFrom() {
+    return from;
+  }
+
+  @Override
+  public void setFrom(String from) {
+    this.from = from;
+  }
+
+  @Override
+  public String getTo() {
+    return to;
+  }
+
+  @Override
+  public void setTo(String to) {
+    this.to = to;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
index 5770ba6..edd7563 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
@@ -26,14 +26,11 @@ import org.apache.ambari.logsearch.model.request.ServiceLogParamDefinition;
 import javax.ws.rs.QueryParam;
 
 public class BaseServiceLogRequest extends BaseLogRequest
-  implements ServiceLogParamDefinition, BundleIdParamDefinition, DateRangeParamDefinition {
+  implements ServiceLogParamDefinition, BundleIdParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_LEVEL)
   private String level;
 
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
-  private String eMessage;
-
   @QueryParam(LogSearchConstants.REQUEST_PARAM_HOST_NAME)
   private String hostName;
 
@@ -46,15 +43,6 @@ public class BaseServiceLogRequest extends BaseLogRequest
   @QueryParam(LogSearchConstants.REQUEST_PARAM_BUNDLE_ID)
   private String bundleId;
 
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
-  private String from;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
-  private String to;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_DATE_RANGE_LABEL)
-  private String dateRangeLabel;
-
   @Override
   public String getLevel() {
     return level;
@@ -66,16 +54,6 @@ public class BaseServiceLogRequest extends BaseLogRequest
   }
 
   @Override
-  public String geteMessage() {
-    return eMessage;
-  }
-
-  @Override
-  public void seteMessage(String eMessage) {
-    this.eMessage = eMessage;
-  }
-
-  @Override
   public String getHostName() {
     return hostName;
   }
@@ -114,34 +92,4 @@ public class BaseServiceLogRequest extends BaseLogRequest
   public void setBundleId(String bundleId) {
     this.bundleId = bundleId;
   }
-
-  @Override
-  public String getFrom() {
-    return from;
-  }
-
-  @Override
-  public void setFrom(String from) {
-    this.from = from;
-  }
-
-  @Override
-  public String getTo() {
-    return to;
-  }
-
-  @Override
-  public void setTo(String to) {
-    this.to = to;
-  }
-
-  @Override
-  public String getDateRangeLabel() {
-    return dateRangeLabel;
-  }
-
-  @Override
-  public void setDateRangeLabel(String dateRangeLabel) {
-    this.dateRangeLabel = dateRangeLabel;
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
index 67502fa..0bdcddf 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
@@ -18,17 +18,21 @@
  */
 package org.apache.ambari.logsearch.model.request.impl;
 
-import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.model.request.FieldParamDefinition;
+import org.apache.ambari.logsearch.model.request.TopParamDefinition;
 
+import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
 
-public class FieldAuditLogRequest extends BaseAuditLogRequest implements FieldParamDefinition {
+public class FieldAuditLogRequest extends BaseLogRequest implements FieldParamDefinition, TopParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_FIELD)
   private String field;
 
+  @PathParam(LogSearchConstants.REQUEST_PARAM_TOP)
+  private Integer top;
+
   @Override
   public String getField() {
     return field;
@@ -38,4 +42,14 @@ public class FieldAuditLogRequest extends BaseAuditLogRequest implements FieldPa
   public void setField(String field) {
     this.field = field;
   }
+
+  @Override
+  public Integer getTop() {
+    return top;
+  }
+
+  @Override
+  public void setTop(Integer top) {
+    this.top = top;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java
deleted file mode 100644
index 0ce788c..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request.impl;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.QueryParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class QueryRequest extends CommonSearchRequest implements QueryParamDefinition {
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_QUERY)
-  private String query;
-
-  @Override
-  public String getQuery() {
-    return query;
-  }
-
-  @Override
-  public void setQuery(String query) {
-    this.query = query;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java
deleted file mode 100644
index 8207c5d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request.impl;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.BundleIdParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class ServiceExtremeDatesRequest extends CommonSearchRequest implements BundleIdParamDefinition {
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_BUNDLE_ID)
-  private String bundleId;
-
-  @Override
-  public String getBundleId() {
-    return bundleId;
-  }
-
-  @Override
-  public void setBundleId(String bundleId) {
-    this.bundleId = bundleId;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogAggregatedInfoRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogAggregatedInfoRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogAggregatedInfoRequest.java
new file mode 100644
index 0000000..84955d8
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogAggregatedInfoRequest.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogAggregatedInfoRequest extends BaseServiceLogRequest {
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentHostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentHostRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentHostRequest.java
new file mode 100644
index 0000000..44250e8
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentHostRequest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import io.swagger.annotations.ApiParam;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceLogComponentHostRequest extends ServiceLogRequest {
+  @QueryParam("componentName")
+  @ApiParam
+  String componentName;
+
+  @Override
+  public String getComponentName() {
+    return componentName;
+  }
+
+  @Override
+  public void setComponentName(String componentName) {
+    this.componentName = componentName;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentLevelRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentLevelRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentLevelRequest.java
new file mode 100644
index 0000000..dd2b8af
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentLevelRequest.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogComponentLevelRequest extends ServiceLogRequest {
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogHostComponentRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogHostComponentRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogHostComponentRequest.java
new file mode 100644
index 0000000..6242362
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogHostComponentRequest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import io.swagger.annotations.ApiParam;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceLogHostComponentRequest extends ServiceLogRequest {
+  @QueryParam("hostName")
+  @ApiParam
+  String hostName;
+
+  @Override
+  public String getHostName() {
+    return hostName;
+  }
+
+  @Override
+  public void setHostName(String hostName) {
+    this.hostName = hostName;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogLevelCountRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogLevelCountRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogLevelCountRequest.java
new file mode 100644
index 0000000..7f0805f
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogLevelCountRequest.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogLevelCountRequest extends BaseServiceLogRequest {
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
index 8067896..c4b0049 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
@@ -32,7 +32,7 @@ public class ServiceLogTruncatedRequest extends ServiceLogRequest implements Log
   private String scrollType;
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_NUMBER_ROWS)
-  private String numberRows;
+  private Integer numberRows;
 
   @Override
   public String getId() {
@@ -55,12 +55,12 @@ public class ServiceLogTruncatedRequest extends ServiceLogRequest implements Log
   }
 
   @Override
-  public String getNumberRows() {
+  public Integer getNumberRows() {
     return numberRows;
   }
 
   @Override
-  public void setNumberRows(String numberRows) {
+  public void setNumberRows(Integer numberRows) {
     this.numberRows = numberRows;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java
deleted file mode 100644
index eec4379..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request.impl;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.QueryParamDefinition;
-import org.apache.ambari.logsearch.model.request.SearchRequest;
-
-import javax.ws.rs.QueryParam;
-
-
-public class SimpleQueryRequest implements SearchRequest, QueryParamDefinition {
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_QUERY)
-  private String query;
-
-  @Override
-  public String getQuery() {
-    return query;
-  }
-
-  @Override
-  public void setQuery(String query) {
-    this.query = query;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java
new file mode 100644
index 0000000..05deebd
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.response;
+
+public class TemplateData {
+
+  private String data;
+
+  public TemplateData(String data) {
+    this.data = data;
+  }
+
+  public String getData() {
+    return data;
+  }
+
+  public void setData(String data) {
+    this.data = data;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
deleted file mode 100644
index 8095faf..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.query;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
-import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
-import org.apache.ambari.logsearch.util.JSONUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
-import org.apache.lucene.analysis.path.PathHierarchyTokenizerFactory;
-import org.apache.lucene.analysis.standard.StandardTokenizerFactory;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.schema.TrieDoubleField;
-import org.apache.solr.schema.TrieFloatField;
-import org.apache.solr.schema.TrieLongField;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-
-@Component
-public class QueryGeneration extends QueryGenerationBase {
-
-  private static Logger logger = Logger.getLogger(QueryGeneration.class);
-
-  @Inject
-  private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
-
-  @Inject
-  private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
-
-  public SolrQuery commonServiceFilterQuery(CommonServiceLogSearchCriteria searchCriteria) {
-    LogType logType = LogType.SERVICE;
-    SolrQuery solrQuery = new SolrQuery();
-    // TODO: check these are used from the UI or not
-    String globalExcludeComp = (String) searchCriteria.getParamValue("gMustNot");
-    String unselectedComp = (String) searchCriteria.getParamValue("unselectComp");
-
-    String givenQuery = (String) searchCriteria.getParamValue("q");
-    String level = searchCriteria.getLevel();
-    String startTime = searchCriteria.getFrom();
-    String endTime = searchCriteria.getTo();
-    String iMessage = searchCriteria.getIncludeMessage();
-    String eMessage = searchCriteria.getExcludeMessage();
-    String selectedComp = searchCriteria.getSelectComp();
-    String bundleId = searchCriteria.getBundleId();
-    String urlHostName = searchCriteria.getHostName();
-    String urlComponentName = searchCriteria.getComponentName();
-    String file_name = searchCriteria.getFileName();
-
-    SolrUtil.setMainQuery(solrQuery, givenQuery);
-
-    setSingleRangeFilter(solrQuery, LogSearchConstants.LOGTIME, startTime, endTime);
-    addFilter(solrQuery, selectedComp, LogSearchConstants.SOLR_COMPONENT, Condition.OR);
-
-    setFilterClauseWithFieldName(solrQuery, level, LogSearchConstants.SOLR_LEVEL, LogSearchConstants.NO_OPERATOR, Condition.OR);
-
-    setFilterClauseForSolrSearchableString(solrQuery, iMessage, Condition.OR, LogSearchConstants.NO_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
-    setFilterClauseForSolrSearchableString(solrQuery, eMessage, Condition.AND, LogSearchConstants.MINUS_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
-
-    applyLogFileFilter(solrQuery, searchCriteria);
-
-    setFilterClauseWithFieldName(solrQuery, globalExcludeComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
-    setFilterClauseWithFieldName(solrQuery, unselectedComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
-
-    urlHostName = SolrUtil.escapeQueryChars(urlHostName);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_HOST, urlHostName);
-    urlComponentName = SolrUtil.escapeQueryChars(urlComponentName);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_COMPONENT, urlComponentName);
-
-    setPagination(solrQuery, searchCriteria);
-    setSortOrderDefaultServiceLog(solrQuery, searchCriteria);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.BUNDLE_ID, bundleId);
-    file_name = SolrUtil.escapeQueryChars(file_name);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_PATH, file_name);
-    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY, logType);
-    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY, logType);
-    
-    return solrQuery;
-  }
-
-  public void applyLogFileFilter(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    String hostLogFile = (String) searchCriteria.getParamValue("hostLogFile");
-    String compLogFile = (String) searchCriteria.getParamValue("compLogFile");
-    String givenQuery = (String) searchCriteria.getParamValue("q");
-    String logfileQuery = "";
-    if (!StringUtils.isBlank(hostLogFile) && !StringUtils.isBlank(compLogFile)) {
-      logfileQuery = LogSearchConstants.SOLR_HOST + ":" + hostLogFile + " " + Condition.AND + " " +
-          LogSearchConstants.SOLR_COMPONENT + ":" + compLogFile;
-      if (!StringUtils.isBlank(givenQuery)) {
-        logfileQuery = "(" + givenQuery + ") " + Condition.AND + " (" + logfileQuery + ")";
-      }
-      if (!StringUtils.isBlank(logfileQuery)) {
-        solrQuery.addFilterQuery(logfileQuery);
-      }
-    }
-  }
-
-  private void setUserSpecificFilter(SearchCriteria searchCriteria, SolrQuery solrQuery, String paramName, String operation,
-      LogType logType) {
-    String queryString = (String) searchCriteria.getParamValue(paramName);
-    if (StringUtils.isBlank(queryString)) {
-      queryString = null;
-    }
-    List<String> conditionQuries = new ArrayList<String>();
-    List<String> referalConditionQuries = new ArrayList<String>();
-    List<String> elments = new ArrayList<String>();
-    List<HashMap<String, Object>> queryList = JSONUtil.jsonToMapObjectList(queryString);
-    if (queryList != null && queryList.size() > 0) {
-      for (HashMap<String, Object> columnListMap : queryList) {
-        String orQuery = "";
-        StringBuilder field = new StringBuilder();
-        if (columnListMap != null) {
-          for (String key : columnListMap.keySet()) {
-            if (!StringUtils.isBlank(key)) {;
-              String value = getOriginalValue(key, "" + columnListMap.get(key));
-              orQuery = putWildCardByType(value, key, logType);
-              if (StringUtils.isBlank(orQuery)) {
-                logger.debug("Removing invalid filter for key :"+key +" and value :" +value );
-                continue;
-              }
-              boolean isSame = false;
-              if (elments.contains(key)) {
-                isSame = true;
-              }
-              if (isSame && !operation.equals(LogSearchConstants.EXCLUDE_QUERY)) {
-                for (String tempCondition : conditionQuries) {
-                  if (tempCondition.contains(key)) {
-                    String newCondtion = tempCondition + " " + Condition.OR.name() + " " + orQuery;
-                    referalConditionQuries.remove(tempCondition);
-                    referalConditionQuries.add(newCondtion);
-                  }
-                }
-                conditionQuries.clear();
-                conditionQuries.addAll(referalConditionQuries);
-              } else {
-                conditionQuries.add(orQuery);
-                referalConditionQuries.add(orQuery);
-              }
-              field.append(key);
-              elments.add(field.toString());
-            }
-          }
-        }
-      }
-    }
-    if (!referalConditionQuries.isEmpty() && !StringUtils.isBlank(operation)) {
-      if (operation.equals(LogSearchConstants.INCLUDE_QUERY)) {
-        for (String filter : referalConditionQuries) {
-          if (!StringUtils.isBlank(filter)) {
-            solrQuery.addFilterQuery(filter);
-          }
-        }
-      } else if (operation.equals(LogSearchConstants.EXCLUDE_QUERY)) {
-        for (String filter : referalConditionQuries) {
-          if (!StringUtils.isBlank(filter)) {
-            filter = LogSearchConstants.MINUS_OPERATOR + filter;
-            solrQuery.addFilterQuery(filter);
-          }
-        }
-      }
-    }
-  }
-
-  public SolrQuery commonAuditFilterQuery(CommonSearchCriteria searchCriteria) {
-    LogType logType = LogType.AUDIT;
-    SolrQuery solrQuery = new SolrQuery();
-    solrQuery.setQuery("*:*");
-
-    String startTime = searchCriteria.getStartTime();
-    String endTime = searchCriteria.getEndTime();
-    String selectedComp = searchCriteria.getMustBe();
-    setFilterClauseWithFieldName(solrQuery, selectedComp, LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.NO_OPERATOR, Condition.OR);
-    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY, logType);
-    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY, logType);
-    setSingleRangeFilter(solrQuery, LogSearchConstants.AUDIT_EVTTIME, startTime, endTime);
-    setPagination(solrQuery, searchCriteria);
-    try {
-      if (searchCriteria.getSortBy() == null || searchCriteria.getSortBy().isEmpty()) {
-        searchCriteria.setSortBy(LogSearchConstants.AUDIT_EVTTIME);
-        searchCriteria.setSortType(SolrQuery.ORDER.desc.toString());
-      }
-    } catch (Exception e) {
-      searchCriteria.setSortBy(LogSearchConstants.AUDIT_EVTTIME);
-      searchCriteria.setSortType(SolrQuery.ORDER.desc.toString());
-    }
-    setSortOrderDefaultServiceLog(solrQuery, searchCriteria);
-    return solrQuery;
-  }
-
-  private String putWildCardByType(String str, String key, LogType logType) {
-    String fieldType;
-    SolrDaoBase solrDaoBase = null;
-    switch (logType) {
-    case AUDIT:
-      fieldType = auditSolrDao.schemaFieldNameMap.get(key);
-      solrDaoBase = auditSolrDao;
-      break;
-    case SERVICE:
-      fieldType = serviceLogsSolrDao.schemaFieldNameMap.get(key);
-      solrDaoBase = serviceLogsSolrDao;
-      if (key.equalsIgnoreCase(LogSearchConstants.SOLR_LOG_MESSAGE)) {
-        return SolrUtil.escapeForLogMessage(key, str);
-      }
-      break;
-    default:
-      // set as null
-      logger.error("Invalid logtype :" + logType);
-      fieldType = null;
-    }
-    if (!StringUtils.isBlank(fieldType)) {
-      if (SolrUtil.isSolrFieldNumber(fieldType, solrDaoBase)) {
-        String value = putEscapeCharacterForNumber(str, fieldType,solrDaoBase);
-        if (!StringUtils.isBlank(value)) {
-          return key + ":" + value;
-        } else {
-          return null;
-        }
-      } else if (checkTokenizer(fieldType, StandardTokenizerFactory.class,solrDaoBase)) {
-        return key + ":" + SolrUtil.escapeForStandardTokenizer(str);
-      } else if (checkTokenizer(fieldType, KeywordTokenizerFactory.class,solrDaoBase)|| "string".equalsIgnoreCase(fieldType)) {
-        return key + ":" + SolrUtil.makeSolrSearchStringWithoutAsterisk(str);
-      } else if (checkTokenizer(fieldType, PathHierarchyTokenizerFactory.class,solrDaoBase)) {
-        return key + ":" + str;
-      }
-    }
-   return key + ":" + "*" + str + "*";
-  }
-
-  private String putEscapeCharacterForNumber(String str,String fieldType,SolrDaoBase solrDaoBase) {
-    if (!StringUtils.isBlank(str)) {
-      str = str.replace("*", "");
-    }
-    String escapeCharSting = parseInputValueAsPerFieldType(str,fieldType,solrDaoBase);
-    if (escapeCharSting == null || escapeCharSting.isEmpty()) {
-      return null;
-    }
-    escapeCharSting = escapeCharSting.replace("-", "\\-");
-    return escapeCharSting;
-  }
-
-  private String parseInputValueAsPerFieldType(String str,String fieldType,SolrDaoBase solrDaoBase ) {
-    try {
-      HashMap<String, Object> fieldTypeInfoMap= SolrUtil.getFieldTypeInfoMap(fieldType,solrDaoBase);
-      String className = (String) fieldTypeInfoMap.get("class");
-      if( className.equalsIgnoreCase(TrieDoubleField.class.getSimpleName())){
-        return ""+ Double.parseDouble(str);
-      }else if(className.equalsIgnoreCase(TrieFloatField.class.getSimpleName())){
-        return ""+ Float.parseFloat(str);
-      }else if(className.equalsIgnoreCase(TrieLongField.class.getSimpleName())){
-        return ""+ Long.parseLong(str);
-      }else {
-        return "" + Integer.parseInt(str);
-      }
-    } catch (Exception e) {
-      logger.debug("Invaid input str: " + str + " For fieldType :" + fieldType);
-      return null;
-    }
-  }
-
-  private String getOriginalValue(String name, String value) {
-    String solrValue = PropertiesHelper.getProperty(name);
-    if (StringUtils.isBlank(solrValue)) {
-      return value;
-    }
-    try {
-      String propertyFieldMappings[] = solrValue.split(LogSearchConstants.LIST_SEPARATOR);
-      if (propertyFieldMappings.length > 0) {
-        HashMap<String, String> propertyFieldValue = new HashMap<String, String>();
-        for (String temp : propertyFieldMappings) {
-          if (!StringUtils.isBlank(temp)) {
-            String arrayValue[] = temp.split(":");
-            if (arrayValue.length > 1) {
-              propertyFieldValue.put(arrayValue[0].toLowerCase(Locale.ENGLISH), arrayValue[1].toLowerCase(Locale.ENGLISH));
-            } else {
-              logger.warn("array length is less than required length 1");
-            }
-          }
-        }
-        String originalValue = propertyFieldValue.get(value.toLowerCase(Locale.ENGLISH));
-        if (!StringUtils.isBlank(originalValue)) {
-          return originalValue;
-        }
-      }
-    } catch (Exception e) {
-      // do nothing
-    }
-    return value;
-  }
-
-
-  private boolean checkTokenizer(String fieldType, Class tokenizerFactoryClass, SolrDaoBase solrDaoBase) {
-    HashMap<String, Object> fieldTypeMap = SolrUtil.getFieldTypeInfoMap(fieldType,solrDaoBase);
-    HashMap<String, Object> analyzer = (HashMap<String, Object>) fieldTypeMap.get("analyzer");
-    if (analyzer != null) {
-      HashMap<String, Object> tokenizerMap = (HashMap<String, Object>) analyzer.get("tokenizer");
-      if (tokenizerMap != null) {
-        String tokenizerClass = (String) tokenizerMap.get("class");
-        if (!StringUtils.isEmpty(tokenizerClass)) {
-          tokenizerClass =tokenizerClass.replace("solr.", "");
-          if (tokenizerClass.equalsIgnoreCase(tokenizerFactoryClass
-              .getSimpleName())) {
-            return true;
-          }
-        }
-      }
-    }
-    return false;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
deleted file mode 100644
index 536f41c..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.query;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
-import org.apache.ambari.logsearch.dao.AuditSolrDao;
-import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrQuery.ORDER;
-
-import com.google.gson.Gson;
-
-import javax.inject.Inject;
-
-public abstract class QueryGenerationBase {
-
-  private static final Logger logger = Logger.getLogger(QueryGenerationBase.class);
-  
-  @Inject
-  protected AuditSolrDao auditSolrDao;
-  
-  @Inject
-  protected ServiceLogsSolrDao serviceLogsSolrDao;
-
-  public enum Condition {
-    OR, AND
-  }
-
-  // SetMethods to apply to the query
-  protected void setFilterClauseForSolrSearchableString(SolrQuery solrQuery, String commaSepratedString, Condition condition,
-      String operator, String messageField) {
-    String filterQuery = "";
-    if (!StringUtils.isBlank(commaSepratedString)) {
-      StringBuilder queryMsg = new StringBuilder();
-      operator = (operator == null ? LogSearchConstants.NO_OPERATOR : operator);
-      String[] msgList = commaSepratedString.split(LogSearchConstants.I_E_SEPRATOR);
-      int count = 0;
-      for (String temp : msgList) {
-        count += 1;
-        if (LogSearchConstants.SOLR_LOG_MESSAGE.equalsIgnoreCase(messageField)) {
-          queryMsg.append(" " + operator + SolrUtil.escapeForLogMessage(messageField, temp));
-        } else {
-          temp = SolrUtil.escapeForStandardTokenizer(temp);
-          if(temp.startsWith("\"") && temp.endsWith("\"")){
-            temp = temp.substring(1);
-            temp = temp.substring(0, temp.length()-1);
-          }
-          temp = "*" + temp + "*";
-          queryMsg.append(" " + operator + messageField + ":" + temp);
-        }
-        if (msgList.length > count){
-          queryMsg.append(" " + condition.name() + " ");
-        }
-      }
-      filterQuery = queryMsg.toString();
-      solrQuery.addFilterQuery(filterQuery);
-      logger.debug("Filter added :- " + filterQuery);
-    }
-  }
-
-  public void setFilterClauseWithFieldName(SolrQuery solrQuery, String commaSepratedString, String field, String operator,
-      Condition condition) {
-    if (!StringUtils.isBlank(commaSepratedString)) {
-      String[] arrayOfSepratedString = commaSepratedString.split(LogSearchConstants.LIST_SEPARATOR);
-      String filterQuery = null;
-      if (Condition.OR.equals(condition)) {
-        filterQuery = SolrUtil.orList(operator + field, arrayOfSepratedString,"");
-      } else if (Condition.AND.equals(condition)) {
-        filterQuery = SolrUtil.andList(operator + field, arrayOfSepratedString,"");
-      }else{
-        logger.warn("Not a valid condition :" + condition.name());
-      }
-      //add
-      if (!StringUtils.isBlank(filterQuery)){
-        solrQuery.addFilterQuery(filterQuery);
-        logger.debug("Filter added :- " + filterQuery);
-      }
-    }
-  }
-
-  public void setSortOrderDefaultServiceLog(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    List<SolrQuery.SortClause> defaultSort = new ArrayList<SolrQuery.SortClause>();
-    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
-      ORDER order = SolrQuery.ORDER.asc;
-      if (!order.toString().equalsIgnoreCase(searchCriteria.getSortType())) {
-        order = SolrQuery.ORDER.desc;
-      }
-      SolrQuery.SortClause logtimeSortClause = SolrQuery.SortClause.create(searchCriteria.getSortBy(), order);
-      defaultSort.add(logtimeSortClause);
-    } else {
-      // by default sorting by logtime and sequence number in Descending order
-      SolrQuery.SortClause logtimeSortClause = SolrQuery.SortClause.create(LogSearchConstants.LOGTIME, SolrQuery.ORDER.desc);
-      defaultSort.add(logtimeSortClause);
-
-    }
-    SolrQuery.SortClause sequenceNumberSortClause = SolrQuery.SortClause.create(LogSearchConstants.SEQUNCE_ID, SolrQuery.ORDER.desc);
-    defaultSort.add(sequenceNumberSortClause);
-    solrQuery.setSorts(defaultSort);
-    logger.debug("Sort Order :-" + defaultSort);
-  }
-
-  public void setFilterFacetSort(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
-      solrQuery.setFacetSort(searchCriteria.getSortBy());
-      logger.info("Sorted By :- " + searchCriteria.getSortBy());
-    }
-  }
-
-  public void setSingleSortOrder(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    List<SolrQuery.SortClause> sort = new ArrayList<SolrQuery.SortClause>();
-    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
-      ORDER order = SolrQuery.ORDER.asc;
-      if (!order.toString().equalsIgnoreCase(searchCriteria.getSortType())) {
-        order = SolrQuery.ORDER.desc;
-      }
-      SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(searchCriteria.getSortBy(), order);
-      sort.add(sortOrder);
-      solrQuery.setSorts(sort);
-      logger.debug("Sort Order :-" + sort);
-    }
-  }
-
-  // Search Criteria has parameter "sort" from it can get list of Sort Order
-  // Example of list can be [logtime desc,seq_num desc]
-  @SuppressWarnings("unchecked")
-  public void setMultipleSortOrder(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    List<SolrQuery.SortClause> sort = new ArrayList<SolrQuery.SortClause>();
-    List<String> sortList = (List<String>) searchCriteria.getParamValue("sort");
-    if (sortList != null) {
-      for (String sortOrder : sortList) {
-        if (!StringUtils.isBlank(sortOrder)) {
-          String sortByAndOrder[] = sortOrder.split(" ");
-          if (sortByAndOrder.length > 1) {
-            ORDER order = sortByAndOrder[1].contains("asc") ? SolrQuery.ORDER.asc : SolrQuery.ORDER.desc;
-            SolrQuery.SortClause solrSortClause = SolrQuery.SortClause.create(sortByAndOrder[0], order);
-            sort.add(solrSortClause);
-            logger.debug("Sort Order :-" + sort);
-          } else {
-            logger.warn("Not a valid sort Clause " + sortOrder);
-          }
-        }
-      }
-      solrQuery.setSorts(sort);
-    }
-  }
-
-  public void setSingleIncludeFilter(SolrQuery solrQuery, String filterType, String filterValue) {
-    if (!StringUtils.isBlank(filterType) && !StringUtils.isBlank(filterValue)) {
-      String filterQuery = buildFilterQuery(filterType, filterValue);
-      solrQuery.addFilterQuery(filterQuery);
-      logger.debug("Filter added :- " + filterQuery);
-    }
-  }
-
-  public void setSingleExcludeFilter(SolrQuery solrQuery, String filterType, String filterValue) {
-    if (!StringUtils.isBlank(filterValue) && !StringUtils.isBlank(filterType)) {
-      String filterQuery = LogSearchConstants.MINUS_OPERATOR + buildFilterQuery(filterType, filterValue);
-      solrQuery.addFilterQuery(filterQuery);
-      logger.debug("Filter added :- " + filterQuery);
-    }
-  }
-
-  public void setSingleRangeFilter(SolrQuery solrQuery, String filterType, String filterFromValue, String filterToValue) {
-    if (!StringUtils.isBlank(filterToValue) && !StringUtils.isBlank(filterType) && !StringUtils.isBlank(filterFromValue)) {
-      String filterQuery = buildInclusiveRangeFilterQuery(filterType, filterFromValue, filterToValue);
-      if (!StringUtils.isBlank(filterQuery)) {
-        solrQuery.addFilterQuery(filterQuery);
-        logger.debug("Filter added :- " + filterQuery);
-      }
-    }
-  }
-
-  public void setPagination(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    Integer startIndex = null;
-    Integer maxRows = null;
-    try {
-      startIndex = (Integer) searchCriteria.getStartIndex();
-      SolrUtil.setStart(solrQuery, startIndex);
-    } catch (ClassCastException e) {
-      SolrUtil.setStart(solrQuery, 0);
-    }
-    try {
-      maxRows = (Integer) searchCriteria.getMaxRows();
-      SolrUtil.setRowCount(solrQuery, maxRows);
-    } catch (ClassCastException e) {
-      SolrUtil.setRowCount(solrQuery, 10);
-    }
-
-    if (startIndex != null && maxRows != null)
-      logger.info("Pagination was set from " + startIndex.intValue() + " to " + maxRows.intValue());
-  }
-
-  public void setSingleORFilter(SolrQuery solrQuery, String filterName1, String value1, String filterName2, String value2) {
-    String filterQuery = filterName1 + ":" + value1 + " " + Condition.OR.name() + " " + filterName2 + ":" + value2;
-    solrQuery.setFilterQueries(filterQuery);
-  }
-
-  // BuildMethods to prepare a particular format as required for solr
-  public String buildInclusiveRangeFilterQuery(String filterType, String filterFromValue, String filterToValue) {
-    String filterQuery = filterType + ":[" + filterFromValue + " TO " + filterToValue + "]";
-    logger.info("Build Filter was :- " + filterQuery);
-    return filterQuery;
-  }
-
-  public String buildFilterQuery(String filterType, String filterValue) {
-    String filterQuery = filterType + ":" + filterValue;
-    logger.info("Build Filter Query was :- " + filterQuery);
-    return filterQuery;
-  }
-
-  public String buildJSONFacetAggregatedFuncitonQuery(String function, String xAxisField) {
-    return "{x:'" + function + "(" + xAxisField + ")'}";
-  }
-
-  public String buildJSONFacetTermTimeRangeQuery(String fieldName, String fieldTime, String from, String to, String unit) {
-    String query = "{";
-    query += "x" + ":{type:terms,field:" + fieldName + ",facet:{y:{type:range,field:" + fieldTime + ",start:\"" + from + "\",end:\"" + to + "\",gap:\"" + unit + "\"}}}";
-    query += "}";
-    logger.info("Build JSONQuery is :- " + query);
-    return query;
-  }
-
-  public String buildJsonFacetTermsRangeQuery(String stackField, String xAxisField) {
-    String jsonQuery = "{ " + stackField + ": { type: terms,field:" + stackField + "," + "facet: {   x: { type: terms, field:" + xAxisField + ",mincount:0,sort:{index:asc}}}}}";
-    logger.info("Build JSONQuery is :- " + jsonQuery);
-    return jsonQuery;
-  }
-
-  public String buidlJSONFacetRangeQueryForNumber(String stackField, String xAxisField, String function) {
-    String jsonQuery = "{ " + stackField + ": { type: terms,field:" + stackField + "," + "facet: {   x:'" + function + "(" + xAxisField + ")'}}}}";
-    logger.info("Build JSONQuery is :- " + jsonQuery);
-    return jsonQuery;
-  }
-
-  private String buildListQuery(String paramValue, String solrFieldName, Condition condition) {
-    if (!StringUtils.isBlank(paramValue)) {
-      String[] values = paramValue.split(LogSearchConstants.LIST_SEPARATOR);
-      switch (condition) {
-      case OR:
-        return SolrUtil.orList(solrFieldName, values,"");
-      case AND:
-        return SolrUtil.andList(solrFieldName, values, "");
-      default:
-        logger.error("Invalid condition " + condition.name());
-      }
-    }
-    return "";
-  }
-
-  protected void addFilter(SolrQuery solrQuery, String paramValue, String solrFieldName, Condition condition) {
-    String filterQuery = buildListQuery(paramValue, solrFieldName, condition);
-    if (!StringUtils.isBlank(filterQuery)) {
-      if (solrQuery != null) {
-        solrQuery.addFilterQuery(filterQuery);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractAuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractAuditLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractAuditLogRequestQueryConverter.java
new file mode 100644
index 0000000..c71ec2e
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractAuditLogRequestQueryConverter.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.Query;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+
+public abstract class AbstractAuditLogRequestQueryConverter<SOURCE extends BaseLogRequest, RESULT extends Query>
+  extends AbstractLogRequestQueryConverter<SOURCE, RESULT>{
+
+  @Override
+  public Sort sort(SOURCE request) {
+    String sortBy = request.getSortBy();
+    String sortType = request.getSortType();
+    Sort.Order defaultSortOrder;
+    if (!StringUtils.isBlank(sortBy)) {
+      Sort.Direction direction = StringUtils.equals(sortType , LogSearchConstants.ASCENDING_ORDER) ? Sort.Direction.ASC : Sort.Direction.DESC;
+      defaultSortOrder = new Sort.Order(direction, sortBy);
+    } else {
+      defaultSortOrder = new Sort.Order(Sort.Direction.DESC, AUDIT_EVTTIME);
+    }
+    Sort.Order secuqnceIdOrder = new Sort.Order(Sort.Direction.DESC, SEQUENCE_ID);
+    return new Sort(defaultSortOrder, secuqnceIdOrder);
+  }
+}


[5/7] ambari git commit: AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
index 1d4f91f..c1022cb 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
@@ -18,1246 +18,349 @@
  */
 package org.apache.ambari.logsearch.manager;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
-import java.text.ParseException;
+import java.io.StringWriter;
 import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
 import java.util.Date;
-import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.TimeZone;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import com.google.common.collect.Lists;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
 import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
 import org.apache.ambari.logsearch.graph.GraphDataGenerator;
-import org.apache.ambari.logsearch.model.response.BarGraphData;
+import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogAggregatedInfoRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentHostRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentLevelRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogHostComponentRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogLevelCountRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
-import org.apache.ambari.logsearch.model.response.CountData;
 import org.apache.ambari.logsearch.model.response.CountDataListResponse;
-import org.apache.ambari.logsearch.model.response.GraphData;
 import org.apache.ambari.logsearch.model.response.GraphDataListResponse;
 import org.apache.ambari.logsearch.model.response.GroupListResponse;
 import org.apache.ambari.logsearch.model.response.LogData;
 import org.apache.ambari.logsearch.model.response.LogListResponse;
-import org.apache.ambari.logsearch.model.response.LogSearchResponse;
-import org.apache.ambari.logsearch.model.response.NameValueData;
 import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
-import org.apache.ambari.logsearch.model.response.NodeData;
 import org.apache.ambari.logsearch.model.response.NodeListResponse;
 import org.apache.ambari.logsearch.model.response.ServiceLogData;
 import org.apache.ambari.logsearch.model.response.ServiceLogResponse;
-import org.apache.ambari.logsearch.query.QueryGenerationBase;
-import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria;
+import org.apache.ambari.logsearch.query.converter.BaseServiceLogRequestQueryConverter;
+import org.apache.ambari.logsearch.query.converter.ServiceLogTruncatedRequestQueryConverter;
 import org.apache.ambari.logsearch.solr.model.SolrComponentTypeLogData;
 import org.apache.ambari.logsearch.solr.model.SolrHostLogData;
 import org.apache.ambari.logsearch.solr.model.SolrServiceLogData;
-import org.apache.ambari.logsearch.util.BizUtil;
+import org.apache.ambari.logsearch.util.DownloadUtil;
 import org.apache.ambari.logsearch.util.DateUtil;
-import org.apache.ambari.logsearch.util.FileUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VSummary;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DateUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.response.FacetField;
 import org.apache.solr.client.solrj.response.FacetField.Count;
-import org.apache.solr.client.solrj.response.PivotField;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import com.google.common.collect.Lists;
-
-@Component
+import org.springframework.core.convert.ConversionService;
+import org.springframework.data.solr.core.DefaultQueryParser;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+import org.springframework.data.solr.core.query.SimpleQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.KEY_LOG_MESSAGE;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
 public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceLogResponse> {
-
   private static final Logger logger = Logger.getLogger(ServiceLogsManager.class);
 
-  private static List<String> cancelByDate = new CopyOnWriteArrayList<String>();
-
-  private static Map<String, String> mapUniqueId = new ConcurrentHashMap<String, String>();
-
-  private enum CONDITION {
-    OR, AND
-  }
+  private static final String SERVICE_LOG_TEMPLATE = "service_log_txt.ftl";
 
   @Inject
   private ServiceLogsSolrDao serviceLogsSolrDao;
   @Inject
   private GraphDataGenerator graphDataGenerator;
   @Inject
-  private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
-
-  public ServiceLogResponse searchLogs(ServiceLogSearchCriteria searchCriteria) {
-    String keyword = searchCriteria.getKeyword();
-    String logId = searchCriteria.getSourceLogId();
-    Boolean isLastPage = searchCriteria.isLastPage();
+  private ConversionService conversionService;
+  @Inject
+  private Configuration freemarkerConfiguration;
 
+  public ServiceLogResponse searchLogs(ServiceLogRequest request) {
+    String event = "/service/logs";
+    String keyword = request.getKeyWord();
+    Boolean isLastPage = request.isLastPage();
+    SimpleQuery solrQuery = conversionService.convert(request, SimpleQuery.class);
     if (!StringUtils.isBlank(keyword)) {
       try {
-        return (ServiceLogResponse) getPageByKeyword(searchCriteria);
+        return (ServiceLogResponse) getPageByKeyword(request, event);
       } catch (SolrException | SolrServerException e) {
         logger.error("Error while getting keyword=" + keyword, e);
-        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-            .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-      }
-    } else if (!StringUtils.isBlank(logId)) {
-      try {
-        return (ServiceLogResponse) getPageByLogId(searchCriteria);
-      } catch (SolrException e) {
-        logger.error("Error while getting keyword=" + keyword, e);
-        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-            .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
       }
     } else if (isLastPage) {
-      SolrQuery lastPageQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-      ServiceLogResponse logResponse = getLastPage(searchCriteria,LogSearchConstants.LOGTIME,serviceLogsSolrDao,lastPageQuery);
+      ServiceLogResponse logResponse = getLastPage(serviceLogsSolrDao, solrQuery, event);
       if(logResponse == null){
         logResponse = new ServiceLogResponse();
       }
       return logResponse;
     } else {
-      SolrQuery solrQuery = queryGenerator
-          .commonServiceFilterQuery(searchCriteria);
-
-      solrQuery.setParam("event", "/service/logs");
-
-      return getLogAsPaginationProvided(solrQuery,
-          serviceLogsSolrDao);
+      return getLogAsPaginationProvided(solrQuery, serviceLogsSolrDao, event);
     }
   }
 
   public GroupListResponse getHosts() {
-    return getFields(LogSearchConstants.SOLR_HOST, SolrHostLogData.class);
-  }
-  
-  private <T extends LogData> GroupListResponse getFields(String field, Class<T> clazz) {
-
-    SolrQuery solrQuery = new SolrQuery();
-    GroupListResponse collection = new GroupListResponse();
-    SolrUtil.setMainQuery(solrQuery, null);
-    SolrUtil.setFacetField(solrQuery,
-        field);
-    SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-    try {
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-      if(response == null){
-        return collection;
-      }
-      FacetField facetField = response
-        .getFacetField(field);
-      if (facetField == null){
-        return collection;
-      }
-      List<Count> fieldList = facetField.getValues();
-      if (fieldList == null){
-        return collection;
-      }
-      SolrDocumentList docList = response.getResults();
-      if(docList == null){
-        return collection;
-      }
-      List<LogData> groupList = getLogDataListByFieldType(clazz, response, fieldList);
-
-      collection.setGroupList(groupList);
-      if(!docList.isEmpty()){
-        collection.setStartIndex((int) docList.getStart());
-        collection.setTotalCount(docList.getNumFound());
-      }
-      return collection;
-    } catch (IOException | SolrServerException | SolrException e) {
-      logger.error(e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-
+    return getFields(HOST, SolrHostLogData.class);
   }
 
   public GroupListResponse getComponents() {
-    return getFields(LogSearchConstants.SOLR_COMPONENT, SolrComponentTypeLogData.class);
-  }
-
-  public GraphDataListResponse getAggregatedInfo(CommonServiceLogSearchCriteria searchCriteria) {
-    SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-    String hierarchy = "host,type,level";
-    GraphDataListResponse graphInfo = new GraphDataListResponse();
-    try {
-      SolrUtil.setMainQuery(solrQuery, null);
-      SolrUtil.setFacetPivot(solrQuery, 1, hierarchy);
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-      if (response == null) {
-        return graphInfo;
-      }
-
-      List<List<PivotField>> hirarchicalPivotField = new ArrayList<List<PivotField>>();
-      List<GraphData> dataList = new ArrayList<>();
-      NamedList<List<PivotField>> namedList = response.getFacetPivot();
-      if (namedList != null) {
-        hirarchicalPivotField = namedList.getAll(hierarchy);
-      }
-      if (!hirarchicalPivotField.isEmpty()) {
-        dataList = buidGraphData(hirarchicalPivotField.get(0));
-      }
-      if (!dataList.isEmpty()) {
-        graphInfo.setGraphData(dataList);
-      }
-
-      return graphInfo;
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
+    return getFields(COMPONENT, SolrComponentTypeLogData.class);
   }
 
-  public List<GraphData> buidGraphData(List<PivotField> pivotFields) {
-    List<GraphData> logList = new ArrayList<>();
-    if (pivotFields != null) {
-      for (PivotField pivotField : pivotFields) {
-        if (pivotField != null) {
-          GraphData logLevel = new GraphData();
-          logLevel.setName("" + pivotField.getValue());
-          logLevel.setCount(Long.valueOf(pivotField.getCount()));
-          if (pivotField.getPivot() != null) {
-            logLevel.setDataList(buidGraphData(pivotField.getPivot()));
-          }
-          logList.add(logLevel);
-        }
-      }
-    }
-    return logList;
+  public GraphDataListResponse getAggregatedInfo(ServiceLogAggregatedInfoRequest request) {
+    SimpleQuery solrDataQuery = new BaseServiceLogRequestQueryConverter().convert(request);
+    SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(solrDataQuery);
+    String hierarchy = String.format("%s,%s,%s", HOST, COMPONENT, LEVEL);
+    solrQuery.setQuery("*:*");
+    SolrUtil.setFacetPivot(solrQuery, 1, hierarchy);
+    QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+    return graphDataGenerator.generateSimpleGraphResponse(response, hierarchy);
   }
 
-  public CountDataListResponse getFieldCount(String field){
-    CountDataListResponse collection = new CountDataListResponse();
-    List<CountData> vCounts = new ArrayList<>();
-    SolrQuery solrQuery = new SolrQuery();
-    SolrUtil.setMainQuery(solrQuery, null);
-    if(field == null){
-      return collection;
-    }
-    SolrUtil.setFacetField(solrQuery, field);
-    try {
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-      if (response == null){
-        return collection;
-      }
-      FacetField facetFields = response.getFacetField(field);
-      if (facetFields == null){
-        return collection;
-      }
-      List<Count> fieldList = facetFields.getValues();
-
-      if(fieldList == null){
-        return collection;
-      }
-
-      for (Count cnt : fieldList) {
-        if (cnt != null) {
-          CountData vCount = new CountData();
-          vCount.setName(cnt.getName());
-          vCount.setCount(cnt.getCount());
-          vCounts.add(vCount);
-        }
-      }
-
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-
-    collection.setvCounts(vCounts);
-    return collection;
-  }
-  
-  public CountDataListResponse getLogLevelCount() {
-    return getFieldCount(LogSearchConstants.SOLR_LEVEL);
+  public CountDataListResponse getFieldCount(String field) {
+    return graphDataGenerator.generateCountResponseByField(serviceLogsSolrDao.process(conversionService.convert(field, SimpleFacetQuery.class)), field);
   }
 
   public CountDataListResponse getComponentsCount() {
-    return getFieldCount(LogSearchConstants.SOLR_COMPONENT);
+    return getFieldCount(COMPONENT);
   }
 
   public CountDataListResponse getHostsCount() {
-    return getFieldCount(LogSearchConstants.SOLR_HOST);
+    return getFieldCount(HOST);
   }
 
-  public List<NodeData> buidTreeData(List<PivotField> pivotFields,
-                                     List<PivotField> pivotFieldHost, SolrQuery query,
-                                     String firstPriority, String secondPriority) {
-    List<NodeData> extensionTree = new ArrayList<>();
-    String hostQuery = null;
-    if (pivotFields != null) {
-      // For Host
-      for (PivotField pivotHost : pivotFields) {
-        if (pivotHost != null) {
-          NodeData hostNode = new NodeData();
-          String name = (pivotHost.getValue() == null ? "" : ""+ pivotHost.getValue());
-          String value = "" + pivotHost.getCount();
-          if(!StringUtils.isBlank(name)){
-            hostNode.setName(name);
-          }
-          if(!StringUtils.isBlank(value)){
-            hostNode.setValue(value);
-          }
-          if(!StringUtils.isBlank(firstPriority)){
-            hostNode.setType(firstPriority);
-          }
-
-          hostNode.setParent(true);
-          hostNode.setRoot(true);
-          PivotField hostPivot = null;
-          for (PivotField searchHost : pivotFieldHost) {
-            if (!StringUtils.isBlank(hostNode.getName())
-                && hostNode.getName().equals(searchHost.getValue())) {
-              hostPivot = searchHost;
-              break;
-            }
-          }
-          List<PivotField> pivotLevelHost = hostPivot.getPivot();
-          if (pivotLevelHost != null) {
-            Collection<NameValueData> logLevelCount = new ArrayList<>();
-            for (PivotField pivotLevel : pivotLevelHost) {
-              if (pivotLevel != null) {
-                NameValueData vnameValue = new NameValueData();
-                String levelName = (pivotLevel.getValue() == null ? "" : ""
-                    + pivotLevel.getValue());
-                vnameValue.setName(levelName.toUpperCase());
-                vnameValue.setValue("" + pivotLevel.getCount());
-                logLevelCount.add(vnameValue);
-              }
-            }
-            hostNode.setLogLevelCount(logLevelCount);
-          }
-
-          query.addFilterQuery(hostQuery);
-          List<PivotField> pivotComponents = pivotHost.getPivot();
-          // For Components
-          if (pivotComponents != null) {
-            Collection<NodeData> componentNodes = new ArrayList<>();
-            for (PivotField pivotComp : pivotComponents) {
-              if (pivotComp != null) {
-                NodeData compNode = new NodeData();
-                String compName = (pivotComp.getValue() == null ? "" : ""
-                    + pivotComp.getValue());
-                compNode.setName(compName);
-                if (!StringUtils.isBlank(secondPriority)) {
-                  compNode.setType(secondPriority);
-                }
-                compNode.setValue("" + pivotComp.getCount());
-                compNode.setParent(false);
-                compNode.setRoot(false);
-                List<PivotField> pivotLevels = pivotComp.getPivot();
-                if (pivotLevels != null) {
-                  Collection<NameValueData> logLevelCount = new ArrayList<>();
-                  for (PivotField pivotLevel : pivotLevels) {
-                    if (pivotLevel != null) {
-                      NameValueData vnameValue = new NameValueData();
-                      String compLevel = pivotLevel.getValue() == null ? ""
-                          : "" + pivotLevel.getValue();
-                      vnameValue.setName((compLevel).toUpperCase());
-
-                      vnameValue.setValue("" + pivotLevel.getCount());
-                      logLevelCount.add(vnameValue);
-                    }
-                  }
-                  compNode.setLogLevelCount(logLevelCount);
-                }
-                componentNodes.add(compNode);
-              }}
-            hostNode.setChilds(componentNodes);
-          }
-          extensionTree.add(hostNode);
-        }}
-    }
-
-    return extensionTree;
-  }
-
-  public NodeListResponse getTreeExtension(ServiceLogSearchCriteria searchCriteria) {
-    SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-    solrQuery.setParam("event", "/getTreeExtension");
-
-    if (searchCriteria.getSortBy() == null) {
-      searchCriteria.setSortBy(LogSearchConstants.SOLR_HOST);
-      searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
-    }
-    queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
-    String hostName = ""
-      + ((searchCriteria.getParamValue("hostName") == null) ? ""
-      : searchCriteria.getParamValue("hostName"));
+  public NodeListResponse getTreeExtension(ServiceLogHostComponentRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(facetQuery);
+    String hostName = request.getHostName() == null ? "" : request.getHostName();
     if (!StringUtils.isBlank(hostName)){
-      solrQuery.addFilterQuery(LogSearchConstants.SOLR_HOST + ":*"
-        + hostName + "*");
+      solrQuery.addFilterQuery(String.format("%s:*%s*", HOST, hostName));
     }
-    String firstHirarchy = "host,type,level";
-    String secondHirarchy = "host,level";
-    NodeListResponse list = new NodeListResponse();
-    try {
-
-      SolrUtil.setFacetPivot(solrQuery, 1, firstHirarchy,
-        secondHirarchy);
-
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-      List<List<PivotField>> listFirstHirarchicalPivotFields = new ArrayList<List<PivotField>>();
-      NamedList<List<PivotField>> firstNamedList = response
-        .getFacetPivot();
-      if (firstNamedList != null) {
-        listFirstHirarchicalPivotFields = firstNamedList
-          .getAll(firstHirarchy);
-      }
-      List<List<PivotField>> listSecondHirarchicalPivotFields = new ArrayList<List<PivotField>>();
-      NamedList<List<PivotField>> secondNamedList = response
-        .getFacetPivot();
-      if (secondNamedList != null) {
-        listSecondHirarchicalPivotFields = secondNamedList
-          .getAll(secondHirarchy);
-      }
-      List<PivotField> firstHirarchicalPivotFields = new ArrayList<PivotField>();
-      List<PivotField> secondHirarchicalPivotFields = new ArrayList<PivotField>();
-      if (!listFirstHirarchicalPivotFields.isEmpty()) {
-        firstHirarchicalPivotFields = listFirstHirarchicalPivotFields
-          .get(0);
-      }
-      if (!listSecondHirarchicalPivotFields.isEmpty()) {
-        secondHirarchicalPivotFields = listSecondHirarchicalPivotFields
-          .get(0);
-      }
-      List<NodeData> dataList = buidTreeData(firstHirarchicalPivotFields,
-        secondHirarchicalPivotFields, solrQuery,
-        LogSearchConstants.HOST, LogSearchConstants.COMPONENT);
-
-      list.setvNodeList(dataList);
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-
-    return list;
+    QueryResponse response = serviceLogsSolrDao.process(solrQuery, "/service/logs/tree");
+    String firstHierarchy = String.format("%s,%s,%s", HOST, COMPONENT, LEVEL);
+    String secondHierarchy = String.format("%s,%s", HOST, LEVEL);
+    return graphDataGenerator.generateServiceNodeTreeFromFacetResponse(response, firstHierarchy, secondHierarchy,
+      LogSearchConstants.HOST, LogSearchConstants.COMPONENT);
   }
 
-  public NodeListResponse getHostListByComponent(ServiceLogSearchCriteria searchCriteria) {
-    SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-    solrQuery.setParam("event", "/service/hosts/components");
+  public NodeListResponse getHostListByComponent(ServiceLogComponentHostRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(facetQuery);
+    solrQuery.setFacetSort(request.getSortBy() == null ? HOST: request.getSortBy());
 
     NodeListResponse list = new NodeListResponse();
-    if (searchCriteria.getSortBy() == null) {
-      searchCriteria.setSortBy(LogSearchConstants.SOLR_HOST);
-      searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
-    }
-    queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
-    String componentName = ""
-      + ((searchCriteria.getParamValue("componentName") == null) ? ""
-      : searchCriteria.getParamValue("componentName"));
+    String componentName = request.getComponentName() == null ? "" : request.getComponentName();
     if (!StringUtils.isBlank(componentName)){
-      solrQuery.addFilterQuery(LogSearchConstants.SOLR_COMPONENT + ":"
+      solrQuery.addFilterQuery(COMPONENT + ":"
         + componentName);
-    } else {
-      return list;
-    }
-
-    String firstHirarchy = "type,host,level";
-    String secondHirarchy = "type,level";
-
-    try {
-      SolrUtil.setFacetPivot(solrQuery, 1, firstHirarchy,
-        secondHirarchy);
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-      List<List<PivotField>> firstHirarchicalPivotFields = null;
-      List<List<PivotField>> secondHirarchicalPivotFields = null;
-      NamedList<List<PivotField>> firstNamedList = response
-        .getFacetPivot();
-      if (firstNamedList != null) {
-        firstHirarchicalPivotFields = firstNamedList
-          .getAll(firstHirarchy);
-        secondHirarchicalPivotFields = firstNamedList
-          .getAll(secondHirarchy);
-      }
-
-      if (firstHirarchicalPivotFields == null
-        || secondHirarchicalPivotFields == null) {
-        return list;
-      }
-
-      List<NodeData> dataList = buidTreeData(
-        firstHirarchicalPivotFields.get(0),
-        secondHirarchicalPivotFields.get(0), solrQuery,
+      QueryResponse response = serviceLogsSolrDao.process(solrQuery, "/service/logs/hosts/components");
+      String firstHierarchy = String.format("%s,%s,%s", COMPONENT, HOST, LEVEL);
+      String secondHierarchy = String.format("%s,%s", COMPONENT, LEVEL);
+      return graphDataGenerator.generateServiceNodeTreeFromFacetResponse(response, firstHierarchy, secondHierarchy,
         LogSearchConstants.COMPONENT, LogSearchConstants.HOST);
-      if(dataList == null){
-        return list;
-      }
-
-      list.setvNodeList(dataList);
+    } else {
       return list;
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
   }
 
-  public NameValueDataListResponse getLogsLevelCount(ServiceLogSearchCriteria sc) {
-    NameValueDataListResponse nameValueList = new NameValueDataListResponse();
-    SolrQuery query = queryGenerator.commonServiceFilterQuery(sc);
-    query.setParam("event", "/service/logs/levels/counts/namevalues");
-    List<NameValueData> logsCounts = getLogLevelFacets(query);
-    nameValueList.setvNameValues(logsCounts);
-
-    return nameValueList;
+  public NameValueDataListResponse getLogsLevelCount(ServiceLogLevelCountRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    QueryResponse response = serviceLogsSolrDao.process(facetQuery, "/service/logs/levels/counts");
+    return graphDataGenerator.getNameValueDataListResponseWithDefaults(response, LogSearchConstants.SUPPORTED_LOG_LEVELS);
   }
 
-  public List<NameValueData> getLogLevelFacets(SolrQuery query) {
-    String defalutValue = "0";
-    HashMap<String, String> map = new HashMap<String, String>();
-    List<NameValueData> logsCounts = new ArrayList<>();
-    try {
-      SolrUtil.setFacetField(query, LogSearchConstants.SOLR_LEVEL);
-      List<Count> logLevelCounts = getFacetCounts(query,
-          LogSearchConstants.SOLR_LEVEL);
-      if (logLevelCounts == null) {
-        return logsCounts;
-      }
-      for (Count count : logLevelCounts) {
-        map.put(count.getName().toUpperCase(), "" + count.getCount());
-      }
-      for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
-        NameValueData nameValue = new NameValueData();
-        String value = map.get(level);
-        if (StringUtils.isBlank(value)) {
-          value = defalutValue;
-        }
-        nameValue.setName(level);
-        nameValue.setValue(value);
-        logsCounts.add(nameValue);
-      }
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + query, e);
-    }
-    return logsCounts;
+  public BarGraphDataListResponse getHistogramData(ServiceGraphRequest request) {
+    SolrQuery solrQuery = conversionService.convert(request, SolrQuery.class);
+    QueryResponse response = serviceLogsSolrDao.process(solrQuery, "/service/logs/histogram");
+    return graphDataGenerator.generateBarGraphDataResponseWithRanges(response, LEVEL, true);
   }
 
-  // Get Facet Count According to FacetFeild
-  public List<Count> getFacetCounts(SolrQuery solrQuery, String facetField)
-    throws SolrServerException, IOException, SolrException {
-    List<Count> list = new ArrayList<FacetField.Count>();
-
-    QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-    if(response == null){
-      return list;
-    }
-
-    FacetField field = response.getFacetField(facetField);
-    if (field == null) {
-      return list;
-    }
-    list = field.getValues();
-
-
-    return list;
-  }
 
-  public LogListResponse getPageByKeyword(ServiceLogSearchCriteria searchCriteria)
+  public LogListResponse getPageByKeyword(ServiceLogRequest request, String event)
     throws SolrServerException {
     String defaultChoice = "0";
-
-    String key = (String) searchCriteria.getKeyword();
-    if(StringUtils.isBlank(key)){
-      throw RESTErrorUtil.createRESTException("Keyword was not given",
-          MessageEnums.DATA_NOT_FOUND);
+    String key = request.getKeyWord();
+    if (StringUtils.isBlank(key)) {
+      throw RESTErrorUtil.createRESTException("Keyword was not given", MessageEnums.DATA_NOT_FOUND);
     }
-
     String keyword = SolrUtil.escapeForStandardTokenizer(key);
 
-    if(keyword.startsWith("\"") && keyword.endsWith("\"")){
+    if (keyword.startsWith("\"") && keyword.endsWith("\"")) {
       keyword = keyword.substring(1);
-      keyword = keyword.substring(0, keyword.length()-1);
+      keyword = keyword.substring(0, keyword.length() - 1);
     }
-    keyword = "*" + keyword + "*";
-
-
-    String keyType = (String) searchCriteria.getKeywordType();
-    QueryResponse queryResponse = null;
-
-    if (!defaultChoice.equals(keyType)) {
-      try {
-        int currentPageNumber = searchCriteria.getPage();
-        int maxRows = searchCriteria.getMaxRows();
-        String nextPageLogID = "";
-
-        int lastLogIndexNumber = ((currentPageNumber + 1)
-          * maxRows);
-        String nextPageLogTime = "";
-
-
-        // Next Page Start Time Calculation
-        SolrQuery nextPageLogTimeQuery = queryGenerator
-          .commonServiceFilterQuery(searchCriteria);
-        nextPageLogTimeQuery.remove("start");
-        nextPageLogTimeQuery.remove("rows");
-        nextPageLogTimeQuery.setStart(lastLogIndexNumber);
-        nextPageLogTimeQuery.setRows(1);
-
-        queryResponse = serviceLogsSolrDao.process(
-            nextPageLogTimeQuery);
-        if(queryResponse == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-
-        SolrDocumentList docList = queryResponse.getResults();
-        if(docList ==null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-
-        SolrDocument solrDoc = docList.get(0);
-
-        Date logDate = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
-        if(logDate == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-        nextPageLogTime = DateUtil
-          .convertDateWithMillisecondsToSolrDate(logDate);
-        nextPageLogID = ""
-          + solrDoc.get(LogSearchConstants.ID);
-
-        if (StringUtils.isBlank(nextPageLogID)){
-          nextPageLogID = "0";
-        }
-
-        String filterQueryListIds = "";
-        // Remove the same Time Ids
-        SolrQuery listRemoveIds = queryGenerator
-          .commonServiceFilterQuery(searchCriteria);
-        listRemoveIds.remove("start");
-        listRemoveIds.remove("rows");
-        queryGenerator.setSingleIncludeFilter(listRemoveIds,
-          LogSearchConstants.LOGTIME, "\"" + nextPageLogTime + "\"");
-        queryGenerator.setSingleExcludeFilter(listRemoveIds,
-          LogSearchConstants.ID, nextPageLogID);
-        SolrUtil.setFl(listRemoveIds, LogSearchConstants.ID);
-        queryResponse = serviceLogsSolrDao.process(
-            listRemoveIds);
-        if(queryResponse == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-
-        SolrDocumentList docListIds = queryResponse.getResults();
-        if(docListIds ==null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-        boolean isFirst = true;
-        for (SolrDocument solrDocId :  docListIds ) {
-          String id = "" + solrDocId.get(LogSearchConstants.ID);
-          if (isFirst) {
-            filterQueryListIds += LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
-            isFirst = false;
-          } else {
-            filterQueryListIds += " "+CONDITION.AND+" " + LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
-          }
-        }
-
-        // Keyword Sequence Number Calculation
-        String endTime = searchCriteria.getTo();
-        String startTime = searchCriteria.getFrom();
-        SolrQuery logTimeThroughRangeQuery = queryGenerator
-          .commonServiceFilterQuery(searchCriteria);
-        logTimeThroughRangeQuery.remove("start");
-        logTimeThroughRangeQuery.remove("rows");
-        logTimeThroughRangeQuery.setRows(1);
-        if (!StringUtils.isBlank(filterQueryListIds)){
-          logTimeThroughRangeQuery.setFilterQueries(filterQueryListIds);
-        }
-
-        String sortByType = searchCriteria.getSortType();
-
-        if (!StringUtils.isBlank(sortByType) && sortByType
-          .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
-
-          queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
-            LogSearchConstants.LOGTIME, nextPageLogTime,
-            endTime);
-          logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
-            LogSearchConstants.LOGTIME + " "
-              + LogSearchConstants.ASCENDING_ORDER);
-
-        } else {
-
-          queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
-            LogSearchConstants.LOGTIME, startTime,
-            nextPageLogTime);
-          logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
-            LogSearchConstants.LOGTIME + " "
-              + LogSearchConstants.DESCENDING_ORDER);
-        }
-        queryGenerator.setSingleIncludeFilter(logTimeThroughRangeQuery,
-          LogSearchConstants.SOLR_KEY_LOG_MESSAGE, keyword);
-
-
-        queryResponse = serviceLogsSolrDao.process(
-            logTimeThroughRangeQuery);
-        if(queryResponse == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-
-        SolrDocumentList documentList = queryResponse.getResults();
-        if(documentList ==null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-
-        SolrDocument solrDocument = new SolrDocument();
-        if (!documentList.isEmpty()){
-          solrDocument = documentList.get(0);
-        }
-
-        Date keywordLogDate = (Date) solrDocument.get(LogSearchConstants.LOGTIME);
-        if(keywordLogDate == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-        String originalKeywordDate = DateUtil
-          .convertDateWithMillisecondsToSolrDate(keywordLogDate);
-        String keywordId = "" + solrDocument.get(LogSearchConstants.ID);
-
-        // Getting Range Count from StartTime To Keyword Log Time
-        SolrQuery rangeLogQuery = nextPageLogTimeQuery.getCopy();
-        rangeLogQuery.remove("start");
-        rangeLogQuery.remove("rows");
-
-        if (!StringUtils.isBlank(sortByType) && sortByType
-          .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
-          keywordLogDate = DateUtils.addMilliseconds(keywordLogDate, 1);
-          String keywordDateTime = DateUtil
-            .convertDateWithMillisecondsToSolrDate(keywordLogDate);
-          queryGenerator.setSingleRangeFilter(rangeLogQuery,
-            LogSearchConstants.LOGTIME, startTime,
-            keywordDateTime);
-        } else {
-          keywordLogDate = DateUtils.addMilliseconds(keywordLogDate, -1);
-          String keywordDateTime = DateUtil
-            .convertDateWithMillisecondsToSolrDate(keywordLogDate);
-          queryGenerator.setSingleRangeFilter(rangeLogQuery,
-            LogSearchConstants.LOGTIME, keywordDateTime,
-            endTime);
-        }
 
+    boolean isNext = !defaultChoice.equals(request.getKeywordType()); // 1 is next, 0 is previous
+    return getPageForKeywordByType(request, keyword, isNext, event);
+  }
 
-        long countNumberLogs = countQuery(rangeLogQuery,serviceLogsSolrDao) - 1;
+  private LogListResponse getPageForKeywordByType(ServiceLogRequest request, String keyword, boolean isNext, String event) {
+    String fromDate = request.getFrom(); // store start & end dates
+    String toDate = request.getTo();
+    boolean timeAscending = LogSearchConstants.ASCENDING_ORDER.equals(request.getSortType());
 
+    int currentPageNumber = Integer.parseInt(request.getPage());
+    int maxRows = Integer.parseInt(request.getPageSize());
+    Date logDate = getDocDateFromNextOrLastPage(request, keyword, isNext, currentPageNumber, maxRows);
+    if (logDate == null) {
+      throw RESTErrorUtil.createRESTException("The keyword " + "\"" + keyword + "\"" + " was not found", MessageEnums.ERROR_SYSTEM);
+    }
 
-        //Adding numbers on
+    String nextOrPreviousPageDate = DateUtil.convertDateWithMillisecondsToSolrDate(logDate);
+    SolrServiceLogData firstKeywordLog = getNextHitForKeyword(request, keyword, isNext, event, timeAscending, nextOrPreviousPageDate);
 
+    long keywordSeqNum = firstKeywordLog.getSeqNum();
+    String keywordLogtime = DateUtil.convertDateWithMillisecondsToSolrDate(firstKeywordLog.getLogTime());
 
-        try {
-          SolrQuery sameIdQuery = queryGenerator
-            .commonServiceFilterQuery(searchCriteria);
-          queryGenerator.setSingleIncludeFilter(sameIdQuery,
-            LogSearchConstants.LOGTIME, "\"" + originalKeywordDate + "\"");
-          SolrUtil.setFl(sameIdQuery, LogSearchConstants.ID);
-          SolrDocumentList sameQueryDocList = serviceLogsSolrDao.process(sameIdQuery)
-            .getResults();
-          for (SolrDocument solrDocumenent : sameQueryDocList) {
-            String id = (String) solrDocumenent
-              .getFieldValue(LogSearchConstants.ID);
-            countNumberLogs++;
-           
-            if (StringUtils.isBlank(id) && id.equals(keywordId)){
-              break;
-            }
-          }
-        } catch (SolrException | SolrServerException | IOException e) {
-          logger.error(e);
-        }
+    long numberOfDateDuplicates = countNumberOfDuplicates(request, isNext, keywordSeqNum, keywordLogtime);
 
-        int start = (int) ((countNumberLogs / maxRows) * maxRows);
-        SolrQuery logIdQuery = nextPageLogTimeQuery.getCopy();
-        rangeLogQuery.remove("start");
-        rangeLogQuery.remove("rows");
-        logIdQuery.setStart(start);
-        logIdQuery.setRows(searchCriteria.getMaxRows());
-        return getLogAsPaginationProvided(logIdQuery, serviceLogsSolrDao);
+    long numberOfLogsUntilFound = getNumberOfLogsUntilFound(request, fromDate, toDate, timeAscending, keywordLogtime, numberOfDateDuplicates);
+    int start = (int) ((numberOfLogsUntilFound / maxRows));
 
-      } catch (Exception e) {
-        //do nothing
-      }
+    request.setFrom(fromDate);
+    request.setTo(toDate);
+    request.setPage(String.valueOf(start));
+    SolrQuery keywordNextPageQuery = new DefaultQueryParser().doConstructSolrQuery(conversionService.convert(request, SimpleQuery.class));
+    return getLogAsPaginationProvided(keywordNextPageQuery, serviceLogsSolrDao, event);
+  }
 
+  private Long getNumberOfLogsUntilFound(ServiceLogRequest request, String fromDate, String toDate, boolean timeAscending,
+                                         String keywordLogtime, long numberOfDateDuplicates) {
+    if (!timeAscending) {
+      request.setTo(toDate);
+      request.setFrom(keywordLogtime);
     } else {
-      try {
-        int currentPageNumber = searchCriteria.getPage();
-        int maxRows = searchCriteria.getMaxRows();
-
-        if (currentPageNumber == 0) {
-          throw RESTErrorUtil.createRESTException("This is first Page Not",
-            MessageEnums.DATA_NOT_FOUND);
-        }
-
-        int firstLogCurrentPage = (currentPageNumber * maxRows);
-        String lastLogsLogTime = "";
-
-        // Next Page Start Time Calculation
-        SolrQuery lastLogTime = queryGenerator
-          .commonServiceFilterQuery(searchCriteria);
-        lastLogTime.remove("start");
-        lastLogTime.remove("rows");
-
-        lastLogTime.setStart(firstLogCurrentPage);
-        lastLogTime.setRows(1);
-
-        queryResponse = serviceLogsSolrDao.process(
-            lastLogTime);
-        if(queryResponse == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-
-        SolrDocumentList docList = queryResponse.getResults();
-        if(docList ==null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-        SolrDocument solrDoc = docList.get(0);
-
-        Date logDate = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
-        String sortByType = searchCriteria.getSortType();
-        lastLogsLogTime = DateUtil
-          .convertDateWithMillisecondsToSolrDate(logDate);
-        String lastLogsLogId = ""
-          + solrDoc.get(LogSearchConstants.ID);
-
-
-        String filterQueryListIds = "";
-        // Remove the same Time Ids
-        SolrQuery listRemoveIds = queryGenerator
-          .commonServiceFilterQuery(searchCriteria);
-        listRemoveIds.remove("start");
-        listRemoveIds.remove("rows");
-        queryGenerator.setSingleIncludeFilter(listRemoveIds,
-          LogSearchConstants.LOGTIME, "\"" + lastLogsLogTime + "\"");
-        queryGenerator.setSingleExcludeFilter(listRemoveIds,
-          LogSearchConstants.ID, lastLogsLogId);
-        SolrUtil.setFl(listRemoveIds, LogSearchConstants.ID);
-        queryResponse = serviceLogsSolrDao.process(
-            lastLogTime);
-        if(queryResponse == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-
-        SolrDocumentList docListIds = queryResponse.getResults();
-        if(docListIds == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-        boolean isFirst = true;
-        for (SolrDocument solrDocId : docListIds) {
-          if (solrDocId != null) {
-            String id = "" + solrDocId.get(LogSearchConstants.ID);
-            if (isFirst) {
-              filterQueryListIds += LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
-              isFirst = false;
-            } else {
-              filterQueryListIds += " "+CONDITION.AND+" " + LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":"
-                  + id;
-            }
-          }
-        }
-
-
-        // Keyword LogTime Calculation
-        String endTime = (String) searchCriteria.getTo();
-        String startTime = searchCriteria.getFrom();
-        SolrQuery logTimeThroughRangeQuery = queryGenerator
-          .commonServiceFilterQuery(searchCriteria);
-        logTimeThroughRangeQuery.remove("start");
-        logTimeThroughRangeQuery.remove("rows");
-        logTimeThroughRangeQuery.setRows(1);
-        queryGenerator.setSingleExcludeFilter(logTimeThroughRangeQuery,
-          LogSearchConstants.ID, lastLogsLogId);
-        if (!StringUtils.isBlank(filterQueryListIds)){
-          logTimeThroughRangeQuery.setFilterQueries(filterQueryListIds);
-        }
-
-        if (!StringUtils.isBlank(sortByType) && sortByType
-          .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
-
-          logTimeThroughRangeQuery.remove(LogSearchConstants.SORT);
-          logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
-            LogSearchConstants.LOGTIME + " "
-              + LogSearchConstants.DESCENDING_ORDER);
-
-
-          queryGenerator.setSingleRangeFilter(
-            logTimeThroughRangeQuery,
-            LogSearchConstants.LOGTIME, startTime,
-            lastLogsLogTime);
-
-        } else {
-
-          logTimeThroughRangeQuery.remove(LogSearchConstants.SORT);
-          logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
-            LogSearchConstants.LOGTIME + " "
-              + LogSearchConstants.ASCENDING_ORDER);
-
-
-          queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
-            LogSearchConstants.LOGTIME, lastLogsLogTime, endTime);
-        }
-        queryGenerator.setSingleIncludeFilter(logTimeThroughRangeQuery,
-          LogSearchConstants.SOLR_KEY_LOG_MESSAGE, keyword);
-
-
-        queryResponse = serviceLogsSolrDao.process(
-            logTimeThroughRangeQuery);
-        if(queryResponse == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-
-        SolrDocumentList documentList = queryResponse.getResults();
-        if(documentList == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-        SolrDocument solrDocument = new SolrDocument();
-        if (!documentList.isEmpty()){
-          solrDocument = documentList.get(0);
-        }
-
-        Date keywordLogDate = (Date) solrDocument.get(LogSearchConstants.LOGTIME);
-        if(keywordLogDate == null){
-          throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-              MessageEnums.ERROR_SYSTEM);
-        }
-        String originalKeywordDate = DateUtil
-          .convertDateWithMillisecondsToSolrDate(keywordLogDate);
-        String keywordId = "" + solrDocument.get(LogSearchConstants.ID);
-
-        // Getting Range Count from StartTime To Keyword Log Time
-        SolrQuery rangeLogQuery = lastLogTime.getCopy();
-        rangeLogQuery.remove("start");
-        rangeLogQuery.remove("rows");
-
-        if (!StringUtils.isBlank(sortByType) && sortByType
-          .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
-       //   keywordLogDate = DateUtil.addMilliSecondsToDate(keywordLogDate, 1);
-          String keywordDateTime = DateUtil
-            .convertDateWithMillisecondsToSolrDate(keywordLogDate);
-          queryGenerator.setSingleRangeFilter(rangeLogQuery,
-            LogSearchConstants.LOGTIME, startTime,
-            keywordDateTime);
-
-
-        } else {
-     //     keywordLogDate = DateUtil.addMilliSecondsToDate(keywordLogDate, -1);
-          String keywordDateTime = DateUtil
-            .convertDateWithMillisecondsToSolrDate(keywordLogDate);
-          queryGenerator.setSingleRangeFilter(rangeLogQuery,
-            LogSearchConstants.LOGTIME, keywordDateTime,
-            endTime);
-        }
-
-
-        long countNumberLogs = countQuery(rangeLogQuery,serviceLogsSolrDao) - 1;
-
-        //Adding numbers on
-        try {
-          SolrQuery sameIdQuery = queryGenerator
-            .commonServiceFilterQuery(searchCriteria);
-          queryGenerator.setSingleIncludeFilter(sameIdQuery,
-            LogSearchConstants.LOGTIME, "\"" + originalKeywordDate + "\"");
-          SolrUtil.setFl(sameIdQuery, LogSearchConstants.ID);
-          SolrDocumentList sameQueryDocList = serviceLogsSolrDao.process(sameIdQuery)
-            .getResults();
-          for (SolrDocument solrDocumenent : sameQueryDocList) {
-            if (solrDocumenent != null) {
-              String id = (String) solrDocumenent
-                  .getFieldValue(LogSearchConstants.ID);
-              countNumberLogs++;
-              if ( StringUtils.isBlank(id) && id.equals(keywordId)) {
-                break;
-              }
-            }
-          }
-        } catch (SolrException | SolrServerException | IOException e) {
-          logger.error(e);
-        }
-        int start = (int) ((countNumberLogs / maxRows) * maxRows);
-
-        SolrQuery logIdQuery = lastLogTime.getCopy();
-        rangeLogQuery.remove("start");
-        rangeLogQuery.remove("rows");
-        logIdQuery.setStart(start);
-        logIdQuery.setRows(searchCriteria.getMaxRows());
-        return getLogAsPaginationProvided(logIdQuery, serviceLogsSolrDao);
-      } catch (Exception e) {
-        //do nothing
-      }
-
+      request.setTo(keywordLogtime);
+      request.setFrom(fromDate);
     }
-    throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
-        MessageEnums.ERROR_SYSTEM);
+    SimpleQuery rangeQuery = conversionService.convert(request, SimpleQuery.class);
+    return serviceLogsSolrDao.count(rangeQuery) - numberOfDateDuplicates;
   }
 
-  private LogSearchResponse getPageByLogId(ServiceLogSearchCriteria searchCriteria) {
-    LogSearchResponse logResponse = new ServiceLogResponse();
-    String endLogTime = (String) searchCriteria.getParamValue("to");
-    if(StringUtils.isBlank(endLogTime)){
-      return logResponse;
-    }
-    long startIndex = 0l;
-
-    String logId = (String) searchCriteria.getParamValue("sourceLogId");
-    if(StringUtils.isBlank(logId)){
-      return logResponse;
+  private long countNumberOfDuplicates(ServiceLogRequest request, boolean isNext, long keywordSeqNum, String keywordLogtime) {
+    request.setFrom(keywordLogtime);
+    request.setTo(keywordLogtime);
+    SimpleQuery duplicationsQuery = conversionService.convert(request, SimpleQuery.class);
+    if (isNext) {
+      duplicationsQuery.addFilterQuery(new SimpleFilterQuery(new SimpleStringCriteria(String.format("%s:[* TO %d]", SEQUENCE_ID, keywordSeqNum - 1))));
+    } else {
+      duplicationsQuery.addFilterQuery(new SimpleFilterQuery(new SimpleStringCriteria(String.format("%s:[%d TO *]", SEQUENCE_ID, keywordSeqNum + 1))));
     }
-    SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-
-    String endTimeMinusOneMilli = "";
-    String logTime = "";
-    try {
-
-      SolrQuery logTimeByIdQuery = new SolrQuery();
-      SolrUtil.setMainQuery(logTimeByIdQuery, null);
-      queryGenerator.setSingleIncludeFilter(logTimeByIdQuery,
-          LogSearchConstants.ID, logId);
-      SolrUtil.setRowCount(solrQuery, 1);
-
-      QueryResponse queryResponse = serviceLogsSolrDao
-          .process(logTimeByIdQuery);
-
-      if(queryResponse == null){
-        return new ServiceLogResponse();
-      }
-
-      SolrDocumentList docList = queryResponse.getResults();
-      Date dateOfLogId = null;
-      if (docList != null && !docList.isEmpty()) {
-        SolrDocument dateLogIdDoc = docList.get(0);
-        if(dateLogIdDoc != null){
-          dateOfLogId = (Date) dateLogIdDoc.get(LogSearchConstants.LOGTIME);
-        }
-      }
-
-      if (dateOfLogId != null) {
-        logTime = DateUtil.convertDateWithMillisecondsToSolrDate(dateOfLogId);
-        Date endDate = DateUtils.addMilliseconds(dateOfLogId, 1);
-        endTimeMinusOneMilli = (String) DateUtil
-            .convertDateWithMillisecondsToSolrDate(endDate);
-      }
+    return serviceLogsSolrDao.count(duplicationsQuery);
+  }
 
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error(e);
+  private SolrServiceLogData getNextHitForKeyword(ServiceLogRequest request, String keyword, boolean isNext, String event, boolean timeAscending, String nextOrPreviousPageDate) {
+    if (hasNextOrAscOrder(isNext, timeAscending)) {
+      request.setTo(nextOrPreviousPageDate);
+    } else {
+      request.setFrom(nextOrPreviousPageDate);
+    }
+    SimpleQuery keywordNextQuery = conversionService.convert(request, SimpleQuery.class);
+    keywordNextQuery.addFilterQuery(new SimpleFilterQuery(new Criteria(KEY_LOG_MESSAGE).contains(keyword)));
+    keywordNextQuery.setRows(1);
+    SolrQuery kewordNextSolrQuery = new DefaultQueryParser().doConstructSolrQuery(keywordNextQuery);
+    kewordNextSolrQuery.setStart(0);
+    if (hasNextOrAscOrder(isNext, timeAscending)) {
+      kewordNextSolrQuery.setSort(LOGTIME, SolrQuery.ORDER.desc);
+    } else {
+      kewordNextSolrQuery.setSort(LOGTIME, SolrQuery.ORDER.asc);
     }
-
-    try {
-      solrQuery.remove(LogSearchConstants.ID);
-      solrQuery.remove(LogSearchConstants.LOGTIME);
-      queryGenerator.setSingleRangeFilter(solrQuery,
-          LogSearchConstants.LOGTIME, endTimeMinusOneMilli, endLogTime);
-      SolrUtil.setRowCount(solrQuery, 0);
-      startIndex = countQuery(solrQuery,serviceLogsSolrDao);
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error(e);
+    kewordNextSolrQuery.addSort(SEQUENCE_ID, SolrQuery.ORDER.desc);
+    QueryResponse  queryResponse = serviceLogsSolrDao.process(kewordNextSolrQuery, event);
+    if (queryResponse == null) {
+      throw RESTErrorUtil.createRESTException("The keyword " + "\"" + keyword + "\"" + " was not found", MessageEnums.ERROR_SYSTEM);
     }
-
-    try {
-      SolrQuery sameIdQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-      queryGenerator.setSingleIncludeFilter(sameIdQuery,
-          LogSearchConstants.LOGTIME, "\"" + logTime + "\"");
-      sameIdQuery.set("fl", LogSearchConstants.ID);
-
-      QueryResponse sameIdResponse = serviceLogsSolrDao.process(sameIdQuery);
-      SolrDocumentList docList = sameIdResponse.getResults();
-
-      for (SolrDocument solrDocumenent : docList) {
-        String id = (String) solrDocumenent
-            .getFieldValue(LogSearchConstants.ID);
-        startIndex++;
-        if (!StringUtils.isBlank(id)) {
-          if (id.equals(logId)) {
-            break;
-          }
-        }
-      }
-
-      SolrQuery logIdQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-      logIdQuery.remove("rows");
-      logIdQuery.remove("start");
-      int start = (int) ((startIndex / searchCriteria.getMaxRows()) * searchCriteria
-          .getMaxRows());
-      logIdQuery.setStart(start);
-      logIdQuery.setRows(searchCriteria.getMaxRows());
-      logResponse = getLogAsPaginationProvided(logIdQuery,
-          serviceLogsSolrDao);
-      return logResponse;
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error(e);
+    List<SolrServiceLogData> solrServiceLogDataList = queryResponse.getBeans(SolrServiceLogData.class);
+    if (!CollectionUtils.isNotEmpty(solrServiceLogDataList)) {
+      throw RESTErrorUtil.createRESTException("The keyword " + "\"" + keyword + "\"" + " was not found", MessageEnums.ERROR_SYSTEM);
     }
-
-    throw RESTErrorUtil.createRESTException("LogId not Found",
-        MessageEnums.ERROR_SYSTEM);
+    return solrServiceLogDataList.get(0);
   }
 
-  @SuppressWarnings("unchecked")
-  public BarGraphDataListResponse getHistogramData(ServiceGraphSearchCriteria searchCriteria) {
-    String deafalutValue = "0";
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-    solrQuery.set("event", "/audit/logs/histogram");
-    String from = getFrom(searchCriteria.getFrom());
-    String to = getTo(searchCriteria.getTo());
-    String unit = getUnit(searchCriteria.getUnit());
-
-    List<BarGraphData> histogramData = new ArrayList<>();
-
-    String jsonHistogramQuery = queryGenerator
-      .buildJSONFacetTermTimeRangeQuery(
-        LogSearchConstants.SOLR_LEVEL,
-        LogSearchConstants.LOGTIME, from, to, unit).replace(
-        "\\", "");
-
-    try {
-      SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
-      SolrUtil.setRowCount(solrQuery,Integer.parseInt(deafalutValue));
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-      if (response == null){
-        return dataList;
-      }
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response
-        .getResponse().get("facets");
-
-      if (jsonFacetResponse == null
-        || jsonFacetResponse.toString().equals("{count=0}")){
-        return dataList;
-      }
-
-      serviceLogsSolrDao.extractValuesFromBuckets(jsonFacetResponse, "x", "y", histogramData);
-
-      Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
-      List<BarGraphData> graphDatas = new ArrayList<BarGraphData>();
-      for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
-        boolean isLevelPresent = false;
-        BarGraphData vData1 = null;
-        for (BarGraphData vData2 : histogramData) {
-          String name = vData2.getName();
-          if (level.contains(name)) {
-            isLevelPresent = true;
-            vData1 = vData2;
-            break;
-          }
-          if (vNameValues.isEmpty()) {
-            Collection<NameValueData> vNameValues2 = vData2
-              .getDataCount();
-            for (NameValueData value : vNameValues2) {
-              NameValueData value2 = new NameValueData();
-              value2.setValue(deafalutValue);
-              value2.setName(value.getName());
-              vNameValues.add(value2);
-            }
-          }
-        }
-        if (!isLevelPresent) {
-          BarGraphData vBarGraphData = new BarGraphData();
-          vBarGraphData.setName(level);
-          vBarGraphData.setDataCount(vNameValues);
-          graphDatas.add(vBarGraphData);
-        } else {
-          graphDatas.add(vData1);
-        }
+  private Date getDocDateFromNextOrLastPage(ServiceLogRequest request, String keyword, boolean isNext, int currentPageNumber, int maxRows) {
+    int lastOrFirstLogIndex;
+    if (isNext) {
+      lastOrFirstLogIndex = ((currentPageNumber + 1) * maxRows);
+    } else {
+      if (currentPageNumber == 0) {
+        throw RESTErrorUtil.createRESTException("This is the first Page", MessageEnums.DATA_NOT_FOUND);
       }
-
-      dataList.setGraphData(graphDatas);
-      return dataList;
-
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error(e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-
+      lastOrFirstLogIndex = (currentPageNumber * maxRows) - 1;
     }
-  }
+    SimpleQuery sq = conversionService.convert(request, SimpleQuery.class);
+    SolrQuery nextPageLogTimeQuery = new DefaultQueryParser().doConstructSolrQuery(sq);
+    nextPageLogTimeQuery.remove("start");
+    nextPageLogTimeQuery.remove("rows");
+    nextPageLogTimeQuery.setStart(lastOrFirstLogIndex);
+    nextPageLogTimeQuery.setRows(1);
 
-  public String cancelFindRequestByDate(String uniqueId) {
-    if (StringUtils.isEmpty(uniqueId)) {
-      logger.error("Unique id is Empty");
-      throw RESTErrorUtil.createRESTException("Unique id is Empty",
-        MessageEnums.DATA_NOT_FOUND);
+    QueryResponse queryResponse = serviceLogsSolrDao.process(nextPageLogTimeQuery);
+    if (queryResponse == null) {
+      throw RESTErrorUtil.createRESTException(String.format("Cannot process next page query for \"%s\" ", keyword), MessageEnums.ERROR_SYSTEM);
     }
-
-    if (cancelByDate.remove(uniqueId)) {
-      mapUniqueId.remove(uniqueId);
-      return "Cancel Request Successfully Procssed ";
+    SolrDocumentList docList = queryResponse.getResults();
+    if (docList == null || docList.isEmpty()) {
+      throw RESTErrorUtil.createRESTException(String.format("Cannot obtain next page element for \"%s\" ", keyword), MessageEnums.ERROR_SYSTEM);
     }
-    return "Cancel Request Unable to Process";
+
+    SolrDocument solrDoc = docList.get(0);
+    return (Date) solrDoc.get(LOGTIME);
   }
 
-  public boolean cancelRequest(String uniqueId) {
-    if (StringUtils.isBlank(uniqueId)) {
-      logger.error("Unique id is Empty");
-      throw RESTErrorUtil.createRESTException("Unique id is Empty",
-        MessageEnums.DATA_NOT_FOUND);
-    }
-    for (String date : cancelByDate) {
-      if (uniqueId.equalsIgnoreCase(date)){
-        return false;
-      }
-    }
-    return true;
+  private boolean hasNextOrAscOrder(boolean isNext, boolean timeAscending) {
+    return isNext && !timeAscending || !isNext && timeAscending;
   }
 
-  public Response exportToTextFile(ServiceLogExportSearchCriteria searchCriteria) {
+  public Response export(ServiceLogExportRequest request) {
     String defaultFormat = "text";
-    SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-    String from = searchCriteria.getFrom();
-    String to = searchCriteria.getTo();
-    String utcOffset = searchCriteria.getUtcOffset();
-    String format = searchCriteria.getFormat();
-
-    format = defaultFormat.equalsIgnoreCase(format) && format != null ? ".txt"
-        : ".json";
-    
-    if(StringUtils.isBlank(utcOffset)){
-      utcOffset = "0";
-    }
+    SimpleQuery solrQuery = conversionService.convert(request, SimpleQuery.class);
+    String from = request.getFrom();
+    String to = request.getTo();
+    String utcOffset = StringUtils.isBlank(request.getUtcOffset()) ? "0" : request.getUtcOffset();
+    String format = request.getFormat() != null && defaultFormat.equalsIgnoreCase(request.getFormat()) ? ".txt" : ".json";
+    String fileName = "Component_Logs_" + DateUtil.getCurrentDateInString();
 
     if (!DateUtil.isDateValid(from) || !DateUtil.isDateValid(to)) {
-      logger.error("Not valid date format. Valid format should be"
-          + LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z);
+      logger.error("Not valid date format. Valid format should be" + LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z);
       throw RESTErrorUtil.createRESTException("Not valid date format. Valid format should be"
-          + LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z,
-          MessageEnums.INVALID_INPUT_DATA);
+          + LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z, MessageEnums.INVALID_INPUT_DATA);
 
     } else {
       from = from.replace("T", " ");
@@ -1266,91 +369,28 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
       to = to.replace("T", " ");
       to = to.replace(".", ",");
 
-      to = DateUtil.addOffsetToDate(to, Long.parseLong(utcOffset),
-          "yyyy-MM-dd HH:mm:ss,SSS");
-      from = DateUtil.addOffsetToDate(from, Long.parseLong(utcOffset),
-          "yyyy-MM-dd HH:mm:ss,SSS");
-    }
-
-    String fileName = DateUtil.getCurrentDateInString();
-    if (searchCriteria.getParamValue("hostLogFile") != null
-      && searchCriteria.getParamValue("compLogFile") != null) {
-      fileName = searchCriteria.getParamValue("hostLogFile") + "_"
-        + searchCriteria.getParamValue("compLogFile");
+      to = DateUtil.addOffsetToDate(to, Long.parseLong(utcOffset), "yyyy-MM-dd HH:mm:ss,SSS");
+      from = DateUtil.addOffsetToDate(from, Long.parseLong(utcOffset), "yyyy-MM-dd HH:mm:ss,SSS");
     }
 
     String textToSave = "";
     try {
       QueryResponse response = serviceLogsSolrDao.process(solrQuery);
       if (response == null) {
-        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-            .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
       }
       SolrDocumentList docList = response.getResults();
       if (docList == null) {
-        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-            .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-      }
-
-      VSummary vsummary = BizUtil.buildSummaryForLogFile(docList);
-      vsummary.setFormat(format);
-      vsummary.setFrom(from);
-      vsummary.setTo(to);
-
-      String includeString = (String) searchCriteria.getParamValue("iMessage");
-      if (StringUtils.isBlank(includeString)) {
-        includeString = "";
-      }
-
-      String include[] = includeString.split(LogSearchConstants.I_E_SEPRATOR);
-
-      for (String inc : include) {
-        includeString = includeString + ",\"" + inc + "\"";
-      }
-      includeString = includeString.replaceFirst(",", "");
-      if (!StringUtils.isBlank(includeString)) {
-        vsummary.setIncludeString(includeString);
-      }
-
-      String excludeString = null;
-      boolean isNormalExcluded = false;
-
-      excludeString = (String) searchCriteria.getParamValue("eMessage");
-      if (StringUtils.isBlank(excludeString)) {
-        excludeString = "";
-      }
-
-      String exclude[] = excludeString.split(LogSearchConstants.I_E_SEPRATOR);
-      for (String exc : exclude) {
-        excludeString = excludeString + ",\"" + exc + "\"";
-      }
-
-      excludeString = excludeString.replaceFirst(",", "");
-      if (!StringUtils.isBlank(excludeString)) {
-        vsummary.setExcludeString(excludeString);
-        isNormalExcluded = true;
-      }
-
-      if (!StringUtils.isBlank(excludeString)) {
-        if (!isNormalExcluded) {
-          excludeString = excludeString.replaceFirst(",", "");
-        }
-        vsummary.setExcludeString(excludeString);
-      }
-
-      for (SolrDocument solrDoc : docList) {
-
-        Date logTimeDateObj = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
-        if(logTimeDateObj != null){
-        String logTime = DateUtil.convertSolrDateToNormalDateFormat(
-            logTimeDateObj.getTime(), Long.parseLong(utcOffset));
-        solrDoc.remove(LogSearchConstants.LOGTIME);
-        solrDoc.addField(LogSearchConstants.LOGTIME, logTime);
-        }
+        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
       }
 
       if (format.toLowerCase(Locale.ENGLISH).equals(".txt")) {
-        textToSave = BizUtil.convertObjectToNormalText(docList);
+        Template template = freemarkerConfiguration.getTemplate(SERVICE_LOG_TEMPLATE);
+        Map<String, Object> models = new HashMap<>();
+        DownloadUtil.fillModelsForLogFile(docList, models, request, format, from, to);
+        StringWriter stringWriter = new StringWriter();
+        template.process(models, stringWriter);
+        textToSave = stringWriter.toString();
       } else if (format.toLowerCase(Locale.ENGLISH).equals(".json")) {
         textToSave = convertObjToString(docList);
       } else {
@@ -1358,222 +398,68 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
             "unsoported format either should be json or text",
             MessageEnums.ERROR_SYSTEM);
       }
-      return FileUtil.saveToFile(textToSave, fileName, vsummary);
-
-    } catch (SolrException | SolrServerException | IOException
-      | ParseException e) {
+      File file = File.createTempFile(fileName, format);
+      FileOutputStream fis = new FileOutputStream(file);
+      fis.write(textToSave.getBytes());
+      return Response
+        .ok(file, MediaType.APPLICATION_OCTET_STREAM)
+        .header("Content-Disposition", "attachment;filename=" + fileName + format)
+        .build();
+    } catch (SolrException | TemplateException | IOException e) {
       logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-  }
-
-  public NodeListResponse getComponentListWithLevelCounts(ServiceLogSearchCriteria searchCriteria) {
-    SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-    solrQuery.setParam("event", "/service/logs/components/levels/counts");
-
-    if (searchCriteria.getSortBy() == null) {
-      searchCriteria.setSortBy(LogSearchConstants.SOLR_COMPONENT);
-      searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
-    }
-    queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
-    String componentLevelHirachy = "type,level";
-    NodeListResponse list = new NodeListResponse();
-    try {
-
-      SolrUtil.setFacetPivot(solrQuery, 1, componentLevelHirachy);
-
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-
-      List<List<PivotField>> listPivotField = new ArrayList<List<PivotField>>();
-      NamedList<List<PivotField>> namedList = response.getFacetPivot();
-      if (namedList != null) {
-        listPivotField = namedList.getAll(componentLevelHirachy);
-      }
-      List<PivotField> secondHirarchicalPivotFields = null;
-      if (listPivotField == null || listPivotField.isEmpty()) {
-        return list;
-      } else {
-        secondHirarchicalPivotFields = listPivotField.get(0);
-      }
-      List<NodeData> datatList = new ArrayList<>();
-      for (PivotField singlePivotField : secondHirarchicalPivotFields) {
-        if (singlePivotField != null) {
-          NodeData comp = new NodeData();
-          comp.setName("" + singlePivotField.getValue());
-          List<PivotField> levelList = singlePivotField.getPivot();
-          List<NameValueData> levelCountList = new ArrayList<>();
-          comp.setLogLevelCount(levelCountList);
-          if(levelList != null){
-            for (PivotField levelPivot : levelList) {
-              NameValueData level = new NameValueData();
-              level.setName(("" + levelPivot.getValue()).toUpperCase());
-              level.setValue("" + levelPivot.getCount());
-              levelCountList.add(level);
-            }
-          }
-          datatList.add(comp);
-        }
-      }
-      list.setvNodeList(datatList);
-      return list;
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error(e.getMessage() + "SolrQuery"+solrQuery);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
   }
 
-  public NameValueDataListResponse getExtremeDatesForBundelId(SearchCriteria searchCriteria) {
-    SolrQuery solrQuery = new SolrQuery();
-    NameValueDataListResponse nameValueList = new NameValueDataListResponse();
-    try {
-      String bundelId = (String) searchCriteria
-        .getParamValue(LogSearchConstants.BUNDLE_ID);
-      if(StringUtils.isBlank(bundelId)){
-        bundelId = "";
-      }
-
-      queryGenerator.setSingleIncludeFilter(solrQuery,
-        LogSearchConstants.BUNDLE_ID, bundelId);
-
-      SolrUtil.setMainQuery(solrQuery, null);
-      solrQuery.setSort(LogSearchConstants.LOGTIME, SolrQuery.ORDER.asc);
-      SolrUtil.setRowCount(solrQuery, 1);
-
-      List<NameValueData> vNameValues = new ArrayList<>();
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-
-      if(response == null){
-        return nameValueList;
-      }
-
-      SolrDocumentList solrDocList = response.getResults();
-      if(solrDocList == null){
-        return nameValueList;
-      }
-      for (SolrDocument solrDoc : solrDocList) {
-
-        Date logTimeAsc = (Date) solrDoc
-          .getFieldValue(LogSearchConstants.LOGTIME);
-        if (logTimeAsc != null) {
-          NameValueData nameValue = new NameValueData();
-          nameValue.setName("From");
-          nameValue.setValue("" + logTimeAsc.getTime());
-          vNameValues.add(nameValue);
-        }
-      }
-
-      solrQuery.clear();
-      SolrUtil.setMainQuery(solrQuery, null);
-      queryGenerator.setSingleIncludeFilter(solrQuery,
-        LogSearchConstants.BUNDLE_ID, bundelId);
-      solrQuery.setSort(LogSearchConstants.LOGTIME, SolrQuery.ORDER.desc);
-      SolrUtil.setRowCount(solrQuery, 1);
-
-      solrDocList.clear();
-      response = serviceLogsSolrDao.process(solrQuery);
-
-      solrDocList = response.getResults();
-      for (SolrDocument solrDoc : solrDocList) {
-        if (solrDoc != null) {
-          Date logTimeDesc = (Date) solrDoc
-              .getFieldValue(LogSearchConstants.LOGTIME);
-
-          if (logTimeDesc != null) {
-            NameValueData nameValue = new NameValueData();
-            nameValue.setName("To");
-            nameValue.setValue("" + logTimeDesc.getTime());
-            vNameValues.add(nameValue);
-          }
-        }
-      }
-      nameValueList.setvNameValues(vNameValues);
-
-
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error(e.getMessage() + "SolrQuery"+solrQuery);
-      nameValueList = new NameValueDataListResponse();
-    }
-    return nameValueList;
+  public NodeListResponse getComponentListWithLevelCounts(ServiceLogComponentLevelRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(facetQuery);
+    solrQuery.setFacetSort(StringUtils.isEmpty(request.getSortBy()) ? COMPONENT: request.getSortBy());
+    QueryResponse response = serviceLogsSolrDao.process(facetQuery, "/service/logs/components/levels/counts");
+    return graphDataGenerator.generateOneLevelServiceNodeTree(response, String.format("%s,%s", COMPONENT, LEVEL));
   }
 
   public String getServiceLogsSchemaFieldsName() {
-    return convertObjToString(serviceLogsSolrDao.schemaFieldNameMap);
+    return convertObjToString(serviceLogsSolrDao.getSolrSchemaFieldDao().getSchemaFieldNameMap());
   }
 
-  public BarGraphDataListResponse getAnyGraphData(ServiceAnyGraphSearchCriteria searchCriteria) {
-    searchCriteria.addParam("fieldTime", LogSearchConstants.LOGTIME);
-    SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-    BarGraphDataListResponse result = graphDataGenerator.getAnyGraphData(searchCriteria, serviceLogsSolrDao, solrQuery);
-    if (result == null) {
-      result = new BarGraphDataListResponse();
-    }
-    return result;
-
+  public BarGraphDataListResponse getAnyGraphCountData(ServiceAnyGraphRequest request) {
+    SimpleFacetQuery solrDataQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    QueryResponse queryResponse = serviceLogsSolrDao.process(solrDataQuery);
+    return graphDataGenerator.getGraphDataWithDefaults(queryResponse, LEVEL, LogSearchConstants.SUPPORTED_LOG_LEVELS);
   }
 
-  public ServiceLogResponse getAfterBeforeLogs(ServiceLogTruncatedSearchCriteria searchCriteria) {
+  public ServiceLogResponse getAfterBeforeLogs(ServiceLogTruncatedRequest request) {
     ServiceLogResponse logResponse = new ServiceLogResponse();
     List<SolrServiceLogData> docList = null;
-    String id = (String) searchCriteria
-      .getParamValue(LogSearchConstants.ID);
-    if (StringUtils.isBlank(id)) {
-      return logResponse;
-
-    }
-    String maxRows = "";
-
-    maxRows = searchCriteria.getNumberRows();
-    if (StringUtils.isBlank(maxRows)){
-      maxRows = ""+maxRows;
-    }
-    String scrollType = searchCriteria.getScrollType();
-    if(StringUtils.isBlank(scrollType)){
-      scrollType = "";
-    }
+    String scrollType = request.getScrollType() != null ? request.getScrollType() : "";
 
     String logTime = null;
     String sequenceId = null;
-    try {
-      SolrQuery solrQuery = new SolrQuery();
-      SolrUtil.setMainQuery(solrQuery,
-        queryGenerator.buildFilterQuery(LogSearchConstants.ID, id));
-      SolrUtil.setRowCount(solrQuery, 1);
-      QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-      if(response == null){
-        return logResponse;
-      }
-      docList = convertToSolrBeans(response);
-      if (docList != null && !docList.isEmpty()) {
-        Date date = docList.get(0).getLogTime();
-        logTime = DateUtil.convertDateWithMillisecondsToSolrDate(date);
-        sequenceId = ""
-          + docList.get(0).getSeqNum();
-      }
-      if (StringUtils.isBlank(logTime)) {
-        return logResponse;
-      }
-    } catch (SolrServerException | SolrException | IOException e) {
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+    SolrQuery solrQuery = new SolrQuery();
+    solrQuery.setQuery("*:*");
+    solrQuery.setRows(1);
+    solrQuery.addFilterQuery(String.format("%s:%s", ID, request.getId()));
+    QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+    if (response == null) {
+      return logResponse;
     }
-    if (LogSearchConstants.SCROLL_TYPE_BEFORE.equals(scrollType)) {
-      logResponse = whenScrollUp(searchCriteria, logTime,
-        sequenceId, maxRows);
-
+    docList = convertToSolrBeans(response);
+    if (docList != null && !docList.isEmpty()) {
+      Date date = docList.get(0).getLogTime();
+      logTime = DateUtil.convertDateWithMillisecondsToSolrDate(date);
+      sequenceId = docList.get(0).getSeqNum().toString();
+    }
+    if (StringUtils.isBlank(logTime)) {
+      return logResponse;
+    }
+    if (LogSearchConstants.SCROLL_TYPE_BEFORE.equals(scrollType) || LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
       List<ServiceLogData> solrDocList = new ArrayList<>();
-      for (ServiceLogData solrDoc : logResponse.getLogList()) {
-        solrDocList.add(solrDoc);
-      }
-      logResponse.setLogList(solrDocList);
+      ServiceLogResponse beforeAfterResponse = whenScroll(request, logTime, sequenceId, scrollType);
+      if (beforeAfterResponse.getLogList() == null) {
         return logResponse;
-
-    } else if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
-      List<ServiceLogData> solrDocList = new ArrayList<>();
-      logResponse = new ServiceLogResponse();
-      for (ServiceLogData solrDoc : whenScrollDown(searchCriteria, logTime,
-          sequenceId, maxRows).getLogList()) {
+      }
+      for (ServiceLogData solrDoc : beforeAfterResponse.getLogList()) {
         solrDocList.add(solrDoc);
       }
       logResponse.setLogList(solrDocList);
@@ -1582,122 +468,30 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
     } else {
       logResponse = new ServiceLogResponse();
       List<ServiceLogData> initial = new ArrayList<>();
-      List<ServiceLogData> before = whenScrollUp(searchCriteria, logTime,
-        sequenceId, maxRows).getLogList();
-      List<ServiceLogData> after = whenScrollDown(searchCriteria, logTime,
-        sequenceId, maxRows).getLogList();
+      List<ServiceLogData> before = whenScroll(request, logTime, sequenceId, LogSearchConstants.SCROLL_TYPE_BEFORE).getLogList();
+      List<ServiceLogData> after = whenScroll(request, logTime, sequenceId, LogSearchConstants.SCROLL_TYPE_AFTER).getLogList();
       if (before != null && !before.isEmpty()) {
         for (ServiceLogData solrDoc : Lists.reverse(before)) {
           initial.add(solrDoc);
         }
       }
-
       initial.add(docList.get(0));
       if (after != null && !after.isEmpty()) {
         for (ServiceLogData solrDoc : after) {
           initial.add(solrDoc);
         }
       }
-
       logResponse.setLogList(initial);
-
       return logResponse;
-
-    }
-  }
-
-  private ServiceLogResponse whenScrollUp(SearchCriteria searchCriteria,
-                                          String logTime, String sequenceId, String maxRows) {
-    SolrQuery solrQuery = new SolrQuery();
-    SolrUtil.setMainQuery(solrQuery, null);
-    try {
-      int seq_num = Integer.parseInt(sequenceId) - 1;
-      sequenceId = "" + seq_num;
-    } catch (Exception e) {
-
     }
-    queryGenerator.setSingleRangeFilter(
-      solrQuery,
-      LogSearchConstants.SEQUNCE_ID, "*", sequenceId);
-
-    queryGenerator.applyLogFileFilter(solrQuery, searchCriteria);
-
-    queryGenerator.setSingleRangeFilter(solrQuery,
-      LogSearchConstants.LOGTIME, "*", logTime);
-    SolrUtil.setRowCount(solrQuery, Integer.parseInt(maxRows));
-    String order1 = LogSearchConstants.LOGTIME + " "
-      + LogSearchConstants.DESCENDING_ORDER;
-    String order2 = LogSearchConstants.SEQUNCE_ID + " "
-      + LogSearchConstants.DESCENDING_ORDER;
-    List<String> sortOrder = new ArrayList<String>();
-    sortOrder.add(order1);
-    sortOrder.add(order2);
-    searchCriteria.addParam(LogSearchConstants.SORT, sortOrder);
-    queryGenerator.setMultipleSortOrder(solrQuery, searchCriteria);
-
-    return getLogAsPaginationProvided(solrQuery, serviceLogsSolrDao);
   }
 
-  private ServiceLogResponse whenScrollDown(SearchCriteria searchCriteria,
-                                            String logTime, String sequenceId, String maxRows) {
-    SolrQuery solrQuery = new SolrQuery();
-    SolrUtil.setMainQuery(solrQuery, null);
-    queryGenerator.applyLogFileFilter(solrQuery, searchCriteria);
-
-    try {
-      int seq_num = Integer.parseInt(sequenceId) + 1;
-      sequenceId = "" + seq_num;
-    } catch (Exception e) {
-
-    }
-    queryGenerator.setSingleRangeFilter(
-      solrQuery,
-      LogSearchConstants.SEQUNCE_ID, sequenceId, "*");
-    queryGenerator.setSingleRangeFilter(solrQuery,
-      LogSearchConstants.LOGTIME, logTime, "*");
-    SolrUtil.setRowCount(solrQuery, Integer.parseInt(maxRows));
-
-    String order1 = LogSearchConstants.LOGTIME + " "
-      + LogSearchConstants.ASCENDING_ORDER;
-    String order2 = LogSearchConstants.SEQUNCE_ID + " "
-      + LogSearchConstants.ASCENDING_ORDER;
-    List<String> sortOrder = new ArrayList<String>();
-    sortOrder.add(order1);
-    sortOrder.add(order2);
-    searchCriteria.addParam(LogSearchConstants.SORT, sortOrder);
-    queryGenerator.setMultipleSortOrder(solrQuery, searchCriteria);
-
-    return getLogAsPaginationProvided(solrQuery, serviceLogsSolrDao);
-  }
-
-  @Scheduled(cron = "${logsearch.solr.warming.cron}")
-  public void warmingSolrServer(){
-    logger.info("solr warming triggered.");
-    SolrQuery solrQuery = new SolrQuery();
-    TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
-    GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
-    utc.setTimeInMillis(new Date().getTime());
-    utc.set(Calendar.HOUR, 0);
-    utc.set(Calendar.MINUTE, 0);
-    utc.set(Calendar.MILLISECOND, 001);
-    utc.set(Calendar.SECOND, 0);
-    DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
-    String from = DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
-    utc.set(Calendar.MILLISECOND, 999);
-    utc.set(Calendar.SECOND, 59);
-    utc.set(Calendar.MINUTE, 59);
-    utc.set(Calendar.HOUR, 23);
-    String to = DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
-    queryGenerator.setSingleRangeFilter(solrQuery,
-        LogSearchConstants.LOGTIME, from,to);
-    String level = LogSearchConstants.FATAL+","+LogSearchConstants.ERROR+","+LogSearchConstants.WARN;
-    queryGenerator.setFilterClauseWithFieldName(solrQuery, level,
-        LogSearchConstants.SOLR_LEVEL, "", QueryGenerationBase.Condition.OR);
-    try {
-      serviceLogsSolrDao.process(solrQuery);
-    } catch (SolrServerException | IOException e) {
-      logger.error("Error while warming solr server",e);
-    }
+  private ServiceLogResponse whenScroll(ServiceLogTruncatedRequest request, String logTime, String sequenceId, String afterOrBefore) {
+    request.setScrollType(afterOrBefore);
+    ServiceLogTruncatedRequestQueryConverter converter = new ServiceLogTruncatedRequestQueryConverter();
+    converter.setLogTime(logTime);
+    converter.setSequenceId(sequenceId);
+    return getLogAsPaginationProvided(converter.convert(request), serviceLogsSolrDao, "service/logs/truncated");
   }
 
   @Override
@@ -1728,6 +522,40 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
     }
   }
 
+  private <T extends LogData> GroupListResponse getFields(String field, Class<T> clazz) {
+    SolrQuery solrQuery = new SolrQuery();
+    solrQuery.setQuery("*:*");
+    GroupListResponse collection = new GroupListResponse();
+    SolrUtil.setFacetField(solrQuery,
+      field);
+    SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
+    QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+    if (response == null) {
+      return collection;
+    }
+    FacetField facetField = response
+      .getFacetField(field);
+    if (facetField == null) {
+      return collection;
+    }
+    List<Count> fieldList = facetField.getValues();
+    if (fieldList == null) {
+      return collection;
+    }
+    SolrDocumentList docList = response.getResults();
+    if (docList == null) {
+      return collection;
+    }
+    List<LogData> groupList = getLogDataListByFieldType(clazz, response, fieldList);
+
+    collection.setGroupList(groupList);
+    if (!docList.isEmpty()) {
+      collection.setStartIndex((int) docList.getStart());
+      collection.setTotalCount(docList.getNumFound());
+    }
+    return collection;
+  }
+
   private <T extends LogData> LogData createNewFieldByType(Class<T> clazz, Count count, String temp) {
     temp = count.getName();
     LogData result = null;
@@ -1745,5 +573,4 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
     }
     throw new UnsupportedOperationException();
   }
-
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java
index 206636a..e8b699e 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java
@@ -24,9 +24,10 @@ import org.apache.log4j.Logger;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.web.authentication.WebAuthenticationDetails;
-import org.springframework.stereotype.Component;
 
-@Component
+import javax.inject.Named;
+
+@Named
 public class SessionManager {
 
   private static final Logger logger = Logger.getLogger(SessionManager.class);


[7/7] ambari git commit: AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Posted by ol...@apache.org.
AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Change-Id: I0e99217fea1de03135b86e007fcb2a3ff6c2e257


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ea644cc4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ea644cc4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ea644cc4

Branch: refs/heads/branch-dev-logsearch
Commit: ea644cc434be39b026826589020ffa12ad3417fb
Parents: 3013589
Author: oleewere <ol...@gmail.com>
Authored: Mon Sep 12 21:35:08 2016 +0200
Committer: oleewere <os...@hortonworks.com>
Committed: Tue Sep 27 21:50:35 2016 +0200

----------------------------------------------------------------------
 .../ambari-logsearch-portal/pom.xml             |   10 +
 .../logsearch/common/ExternalServerClient.java  |    4 +-
 .../logsearch/common/LogSearchConstants.java    |   51 +-
 .../apache/ambari/logsearch/common/LogType.java |   34 +
 .../logsearch/conf/ApplicationConfig.java       |   13 +
 .../ambari/logsearch/conf/SolrConfig.java       |   11 +
 .../ambari/logsearch/dao/AuditSolrDao.java      |   23 +-
 .../logsearch/dao/ServiceLogsSolrDao.java       |   21 +-
 .../ambari/logsearch/dao/SolrAliasDao.java      |    8 +-
 .../ambari/logsearch/dao/SolrCollectionDao.java |    4 +-
 .../ambari/logsearch/dao/SolrDaoBase.java       |   99 +-
 .../logsearch/dao/SolrSchemaFieldDao.java       |   24 +-
 .../ambari/logsearch/dao/UserConfigSolrDao.java |   23 +-
 .../ambari/logsearch/doc/DocConstants.java      |   18 +-
 .../logsearch/graph/GraphDataGenerator.java     |  625 +++---
 .../logsearch/graph/GraphDataGeneratorBase.java |  169 --
 .../logsearch/manager/AuditLogsManager.java     |  478 +----
 .../ambari/logsearch/manager/ManagerBase.java   |  137 +-
 .../ambari/logsearch/manager/PublicManager.java |    4 +-
 .../logsearch/manager/ServiceLogsManager.java   | 1771 +++---------------
 .../logsearch/manager/SessionManager.java       |    5 +-
 .../logsearch/manager/UserConfigManager.java    |   70 +-
 .../model/request/LogParamDefinition.java       |    7 +
 .../request/LogTruncatedParamDefinition.java    |    4 +-
 .../model/request/QueryParamDefinition.java     |   32 -
 .../request/ServiceLogParamDefinition.java      |   13 -
 .../model/request/TopParamDefinition.java       |   31 +
 .../model/request/impl/AnyGraphRequest.java     |  109 --
 .../request/impl/AuditBarGraphRequest.java      |    2 +-
 .../request/impl/AuditComponentRequest.java     |   25 +
 .../model/request/impl/AuditLogRequest.java     |    2 +-
 .../request/impl/AuditServiceLoadRequest.java   |   25 +
 .../model/request/impl/BaseAuditLogRequest.java |   53 -
 .../model/request/impl/BaseLogRequest.java      |   43 +-
 .../request/impl/BaseServiceLogRequest.java     |   54 +-
 .../request/impl/FieldAuditLogRequest.java      |   18 +-
 .../model/request/impl/QueryRequest.java        |   40 -
 .../impl/ServiceExtremeDatesRequest.java        |   41 -
 .../impl/ServiceLogAggregatedInfoRequest.java   |   25 +
 .../impl/ServiceLogComponentHostRequest.java    |   39 +
 .../impl/ServiceLogComponentLevelRequest.java   |   25 +
 .../impl/ServiceLogHostComponentRequest.java    |   39 +
 .../impl/ServiceLogLevelCountRequest.java       |   25 +
 .../impl/ServiceLogTruncatedRequest.java        |    6 +-
 .../model/request/impl/SimpleQueryRequest.java  |   42 -
 .../logsearch/model/response/TemplateData.java  |   36 +
 .../ambari/logsearch/query/QueryGeneration.java |  340 ----
 .../logsearch/query/QueryGenerationBase.java    |  282 ---
 .../AbstractAuditLogRequestQueryConverter.java  |   47 +
 .../AbstractCommonAuditLogRequestConverter.java |   44 -
 .../AbstractCommonSearchRequestConverter.java   |   55 -
 ...bstractCommonServiceLogRequestConverter.java |   51 -
 .../query/converter/AbstractConverterAware.java |    4 +-
 .../AbstractDateRangeFacetQueryConverter.java   |   55 +
 .../AbstractLogRequestFacetQueryConverter.java  |   61 +
 .../AbstractLogRequestQueryConverter.java       |   44 +
 .../AbstractSearchRequestQueryConverter.java    |  173 ++
 .../converter/AnyGraphRequestConverter.java     |   39 -
 .../AuditBarGraphRequestConverter.java          |   34 -
 .../AuditBarGraphRequestQueryConverter.java     |   40 +
 .../AuditComponentsRequestQueryConverter.java   |   62 +
 .../converter/AuditLogRequestConverter.java     |   34 -
 .../AuditLogRequestQueryConverter.java          |   44 +
 .../AuditServiceLoadRequestQueryConverter.java  |   47 +
 .../converter/BaseAuditLogRequestConverter.java |   33 -
 .../BaseServiceLogRequestConverter.java         |   33 -
 .../BaseServiceLogRequestQueryConverter.java    |   82 +
 .../FieldAuditLogRequestConverter.java          |   34 -
 .../FieldAuditLogRequestQueryConverter.java     |   48 +
 .../FieldBarGraphRequestConverter.java          |   35 -
 .../ServiceAnyGraphRequestConverter.java        |   39 -
 .../ServiceExtremeDatesRequestConverter.java    |   34 -
 .../converter/ServiceGraphRequestConverter.java |   34 -
 ...ServiceLogAnyGraphRequestQueryConverter.java |   46 +
 ...eLogComponentLevelRequestQueryConverter.java |   61 +
 ...eLogComponentRequestFacetQueryConverter.java |   62 +
 .../ServiceLogExportRequestConverter.java       |   35 -
 ...rviceLogLevelCountRequestQueryConverter.java |   46 +
 ...eLogLevelDateRangeRequestQueryConverter.java |   55 +
 .../converter/ServiceLogRequestConverter.java   |   39 -
 ...erviceLogTreeRequestFacetQueryConverter.java |   63 +
 .../ServiceLogTruncatedRequestConverter.java    |   36 -
 ...erviceLogTruncatedRequestQueryConverter.java |   95 +
 .../converter/SimpleQueryRequestConverter.java  |   35 -
 .../StringFieldFacetQueryConverter.java         |   44 +
 .../converter/UserExportRequestConverter.java   |   36 -
 .../UserExportRequestQueryConverter.java        |   49 +
 .../query/model/AnyGraphSearchCriteria.java     |   77 -
 .../model/AuditBarGraphSearchCriteria.java      |   33 -
 .../query/model/AuditLogSearchCriteria.java     |   33 -
 .../model/CommonServiceLogSearchCriteria.java   |   88 -
 .../model/FieldAuditBarGraphSearchCriteria.java |   32 -
 .../model/FieldAuditLogSearchCriteria.java      |   32 -
 .../model/ServiceAnyGraphSearchCriteria.java    |   60 -
 .../model/ServiceExtremeDatesCriteria.java      |   32 -
 .../query/model/ServiceGraphSearchCriteria.java |   32 -
 .../model/ServiceLogExportSearchCriteria.java   |   40 -
 .../query/model/ServiceLogSearchCriteria.java   |   65 -
 .../ServiceLogTruncatedSearchCriteria.java      |   48 -
 .../query/model/UserExportSearchCriteria.java   |   31 -
 .../logsearch/rest/AuditLogsResource.java       |   79 +-
 .../ambari/logsearch/rest/PublicResource.java   |    4 +-
 .../logsearch/rest/ServiceLogsResource.java     |   88 +-
 .../logsearch/rest/UserConfigResource.java      |    4 +-
 .../ambari/logsearch/solr/SolrConstants.java    |   62 +
 .../apache/ambari/logsearch/util/BizUtil.java   |  261 ---
 .../apache/ambari/logsearch/util/DateUtil.java  |    9 +
 .../ambari/logsearch/util/DownloadUtil.java     |  176 ++
 .../apache/ambari/logsearch/util/FileUtil.java  |   84 -
 .../apache/ambari/logsearch/util/SolrUtil.java  |  292 +--
 .../LogsearchKRBAuthenticationFilter.java       |    1 -
 .../LogsearchAuthenticationProvider.java        |    4 +-
 ...rchExternalServerAuthenticationProvider.java |    9 +-
 .../LogsearchFileAuthenticationProvider.java    |    4 +-
 .../LogsearchLdapAuthenticationProvider.java    |    4 +-
 .../LogsearchSimpleAuthenticationProvider.java  |    4 +-
 .../src/main/resources/default.properties       |    1 -
 .../main/resources/templates/audit_log_txt.ftl  |   42 +
 .../resources/templates/service_log_txt.ftl     |   36 +
 .../scripts/collection_bases/VLogListBase.js    |    2 +-
 .../src/main/webapp/scripts/utils/ViewUtils.js  |    2 +-
 .../scripts/views/audit/AuditAggregatedView.js  |    6 +-
 .../scripts/views/dashboard/LogLevelBoxView.js  |    2 +-
 .../views/filter/CreateLogfeederFilterView.js   |    6 +-
 .../views/tabs/HierarchyTabLayoutView.js        |    1 +
 .../troubleshoot/TroubleShootLayoutView.js      |    6 +-
 .../webapp/templates/tabs/LogFileView_tmpl.html |   50 +-
 ...BaseServiceLogRequestQueryConverterTest.java |   78 +
 .../logging/LoggingRequestHelperImpl.java       |    2 +-
 129 files changed, 3143 insertions(+), 5647 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/pom.xml b/ambari-logsearch/ambari-logsearch-portal/pom.xml
index a1d1bfc..5485ca1 100755
--- a/ambari-logsearch/ambari-logsearch-portal/pom.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/pom.xml
@@ -757,5 +757,15 @@
       <artifactId>spring-data-solr</artifactId>
       <version>${spring-data-solr.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.freemarker</groupId>
+      <artifactId>freemarker</artifactId>
+      <version>2.3.20</version>
+    </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
index 9682a3d..c476b9d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.ws.rs.client.Invocation;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
@@ -33,12 +34,11 @@ import org.apache.log4j.Logger;
 import org.glassfish.jersey.client.JerseyClient;
 import org.glassfish.jersey.client.JerseyClientBuilder;
 import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.springframework.stereotype.Component;
 
 /**
  * Layer to send REST request to External server using jersey client
  */
-@Component
+@Named
 public class ExternalServerClient {
 
   private static Logger LOG = Logger.getLogger(ExternalServerClient.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
index d9d3b86..4e23146 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
@@ -29,7 +29,7 @@ public class LogSearchConstants {
   public static final String FATAL = "FATAL";
   public static final String UNKNOWN = "UNKNOWN";
   
-  public static final String[] SUPPORTED_LOG_LEVEL ={FATAL,ERROR,WARN,INFO,DEBUG,TRACE,UNKNOWN};
+  public static final String[] SUPPORTED_LOG_LEVELS = {FATAL, ERROR, WARN, INFO, DEBUG, TRACE, UNKNOWN};
 
   // Application Constants
   public static final String HOST = "H";
@@ -46,40 +46,10 @@ public class LogSearchConstants {
   public static final String COMPOSITE_KEY = "composite_filtername-username";
   public static final String SHARE_NAME_LIST = "share_username_list";
 
-  // SOLR Document Constants for ServiceLogs
-  public static final String BUNDLE_ID = "bundle_id";
-  public static final String LOGTIME = "logtime";
-  public static final String SEQUNCE_ID = "seq_num";
-  public static final String SOLR_COMPONENT = "type";
-  public static final String SOLR_LOG_MESSAGE = "log_message";
-  public static final String SOLR_KEY_LOG_MESSAGE = "key_log_message";
-  public static final String SOLR_HOST = "host";
-  public static final String SOLR_LEVEL = "level";
-  public static final String SOLR_THREAD_NAME = "thread_name";
-  public static final String SOLR_LOGGER_NAME = "logger_name";
-  public static final String SOLR_FILE = "file";
-  public static final String SOLR_LINE_NUMBER = "line_number";
-  public static final String SOLR_PATH = "path";
-
-  //SOLR Document Constant for audit log
-  public static final String AUDIT_COMPONENT = "repo";
-  public static final String AUDIT_EVTTIME = "evtTime";
-  public static final String AUDIT_REQUEST_USER = "reqUser";
-
-  // Operator's
-  public static final String MINUS_OPERATOR = "-";
-  public static final String NO_OPERATOR = "";
-
-  //operation
-  public static final String EXCLUDE_QUERY = "excludeQuery";
-  public static final String INCLUDE_QUERY = "includeQuery";
-
   // Seprator's
   public static final String I_E_SEPRATOR = "\\|i\\:\\:e\\|";
 
   //SUFFIX
-  public static final String UI_SUFFIX = "@UI@";
-  public static final String SOLR_SUFFIX = "@Solr@";
   public static final String NGRAM_SUFFIX = "ngram_";
 
   //Date Format for SOLR
@@ -96,35 +66,21 @@ public class LogSearchConstants {
 
   // logfeeder 
   public static final String LOGFEEDER_FILTER_NAME = "log_feeder_config";
-  public static final String LIST_SEPARATOR = ",";
-  
+
   public static final String SORT = "sort";
   public static final String FL = "fl";
   
   //Facet Constant
   public static final String FACET_FIELD = "facet.field";
-  public static final String FACET_MINCOUNT = "facet.mincount";
-  public static final String FACET_JSON_FIELD = "json.facet";
   public static final String FACET_PIVOT = "facet.pivot";
   public static final String FACET_PIVOT_MINCOUNT = "facet.pivot.mincount";
-  public static final String FACET_DATE = "facet.date";
-  public static final String FACET_DATE_START = "facet.date.start";
-  public static final String FACET_DATE_END = "facet.date.end";
-  public static final String FACET_DATE_GAP = "facet.date.gap";
-  public static final String FACET_RANGE = "facet.range";
-  public static final String FACET_RANGE_START = "facet.range.start";
-  public static final String FACET_RANGE_END = "facet.range.end";
-  public static final String FACET_RANGE_GAP = "facet.range.gap";
-  public static final String FACET_GROUP = "group";
-  public static final String FACET_GROUP_MAIN = "group.main";
-  public static final String FACET_GROUP_FIELD = "group.field";
 
   // Request params
-  public static final String REQUEST_PARAM_QUERY = "q";
   public static final String REQUEST_PARAM_XAXIS = "xAxis";
   public static final String REQUEST_PARAM_YAXIS = "yAxis";
   public static final String REQUEST_PARAM_STACK_BY = "stackBy";
   public static final String REQUEST_PARAM_UNIT = "unit";
+  public static final String REQUEST_PARAM_TOP = "top";
   public static final String REQUEST_PARAM_BUNDLE_ID = "bundle_id";
   public static final String REQUEST_PARAM_START_INDEX = "startIndex";
   public static final String REQUEST_PARAM_PAGE = "page";
@@ -151,7 +107,6 @@ public class LogSearchConstants {
   public static final String REQUEST_PARAM_HOST_NAME = "host_name";
   public static final String REQUEST_PARAM_COMPONENT_NAME = "component_name";
   public static final String REQUEST_PARAM_FILE_NAME = "file_name";
-  public static final String REQUEST_PARAM_DATE_RANGE_LABEL = "dateRangeLabel";
   public static final String REQUEST_PARAM_KEYWORD = "find";
   public static final String REQUEST_PARAM_SOURCE_LOG_ID = "sourceLogId";
   public static final String REQUEST_PARAM_KEYWORD_TYPE = "keywordType";

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java
new file mode 100644
index 0000000..2e6cddb
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.common;
+
+public enum LogType {
+  SERVICE("Service"),
+  AUDIT("Audit");
+
+  private String label;
+
+  private LogType(String label) {
+    this.label = label;
+  }
+
+  public String getLabel() {
+    return label;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java
index b279a83..82a09b2 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java
@@ -18,12 +18,16 @@
  */
 package org.apache.ambari.logsearch.conf;
 
+import freemarker.template.TemplateException;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.PropertySource;
 import org.springframework.context.support.ConversionServiceFactoryBean;
 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean;
+
+import java.io.IOException;
 
 @Configuration
 @ComponentScan("org.apache.ambari.logsearch")
@@ -42,4 +46,13 @@ public class ApplicationConfig {
     return conversionServiceFactoryBean;
   }
 
+  @Bean
+  public freemarker.template.Configuration freemarkerConfiguration() throws IOException, TemplateException {
+    FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
+    factoryBean.setPreferFileSystemAccess(false);
+    factoryBean.setTemplateLoaderPath("classpath:/templates");
+    factoryBean.afterPropertiesSet();
+    return factoryBean.getObject();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
index 7508fb1..4868409 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
@@ -18,6 +18,7 @@
  */
 package org.apache.ambari.logsearch.conf;
 
+import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
 import org.apache.ambari.logsearch.solr.AmbariSolrCloudClient;
 import org.apache.ambari.logsearch.solr.AmbariSolrCloudClientBuilder;
 import org.apache.commons.lang.StringUtils;
@@ -79,6 +80,16 @@ public class SolrConfig {
       solrUserConfigPropsConfig.getCollection()));
   }
 
+  @Bean(name = "serviceSolrFieldDao")
+  public SolrSchemaFieldDao serviceSolrFieldDao() {
+    return new SolrSchemaFieldDao();
+  }
+
+  @Bean(name = "auditSolrFieldDao")
+  public SolrSchemaFieldDao auditSolrFieldDao() {
+    return new SolrSchemaFieldDao();
+  }
+
   private CloudSolrClient createClient(String solrUrl, String zookeeperConnectString, String defaultCollection) {
     if (StringUtils.isNotEmpty(zookeeperConnectString)) {
       CloudSolrClient cloudSolrClient = new CloudSolrClient(zookeeperConnectString);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
index 8d6a4da..959d6f4 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
@@ -21,17 +21,15 @@ package org.apache.ambari.logsearch.dao;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 
-@Component
+@Named
 public class AuditSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(AuditSolrDao.class);
@@ -40,7 +38,7 @@ public class AuditSolrDao extends SolrDaoBase {
   private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
 
   @Inject
-  @Qualifier("auditSolrTemplate")
+  @Named("auditSolrTemplate")
   private SolrTemplate auditSolrTemplate;
 
   @Inject
@@ -50,6 +48,7 @@ public class AuditSolrDao extends SolrDaoBase {
   private SolrCollectionDao solrCollectionDao;
 
   @Inject
+  @Named("auditSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   public AuditSolrDao() {
@@ -57,8 +56,8 @@ public class AuditSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) auditSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return auditSolrTemplate;
   }
 
   @PostConstruct
@@ -71,13 +70,17 @@ public class AuditSolrDao extends SolrDaoBase {
       boolean createAlias = (aliasNameIn != null && !StringUtils.isBlank(rangerAuditCollection));
       solrCollectionDao.setupCollections(getSolrClient(), solrAuditLogPropsConfig);
       if (createAlias) {
-        solrAliasDao.setupAlias(solrSchemaFieldDao, getSolrClient(), solrAuditLogPropsConfig, this);
+        solrAliasDao.setupAlias(solrSchemaFieldDao, getSolrClient(), solrAuditLogPropsConfig);
       } else {
-        solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrAuditLogPropsConfig, this);
+        solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrAuditLogPropsConfig);
       }
     } catch (Exception e) {
       LOG.error("Error while connecting to Solr for audit logs : solrUrl=" + solrAuditLogPropsConfig.getSolrUrl() + ", zkConnectString=" +
           solrAuditLogPropsConfig.getZkConnectString() + ", collection=" + solrAuditLogPropsConfig.getCollection(), e);
     }
   }
+
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
index a6f5acf..0e1d57c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
@@ -21,16 +21,14 @@ package org.apache.ambari.logsearch.dao;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 
-@Component
+@Named
 public class ServiceLogsSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(ServiceLogsSolrDao.class);
@@ -42,10 +40,11 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
   private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
 
   @Inject
-  @Qualifier("serviceSolrTemplate")
+  @Named("serviceSolrTemplate")
   private SolrTemplate serviceSolrTemplate;
 
   @Inject
+  @Named("serviceSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   public ServiceLogsSolrDao() {
@@ -53,8 +52,8 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) serviceSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return serviceSolrTemplate;
   }
 
   @PostConstruct
@@ -63,11 +62,15 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
     try {
       solrCollectionDao.checkSolrStatus(getSolrClient());
       solrCollectionDao.setupCollections(getSolrClient(), solrServiceLogPropsConfig);
-      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrServiceLogPropsConfig, this);
+      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrServiceLogPropsConfig);
     } catch (Exception e) {
       LOG.error("error while connecting to Solr for service logs : solrUrl=" + solrServiceLogPropsConfig.getSolrUrl()
         + ", zkConnectString=" + solrServiceLogPropsConfig.getZkConnectString()
         + ", collection=" + solrServiceLogPropsConfig.getCollection(), e);
     }
   }
+
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
index 81471d3..6389446 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
@@ -26,16 +26,16 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.response.CollectionAdminResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 
-@Component
+@Named
 public class SolrAliasDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrAliasDao.class);
@@ -46,7 +46,7 @@ public class SolrAliasDao {
   private SolrCollectionDao solrCollectionDao;
 
   protected void setupAlias(final SolrSchemaFieldDao solrSchemaFieldDao, final CloudSolrClient solrClient,
-                            final SolrAuditLogPropsConfig solrPropsConfig, final SolrDaoBase solrDaoBase) throws Exception {
+                            final SolrAuditLogPropsConfig solrPropsConfig) throws Exception {
     final Collection<String> collectionListIn = Arrays.asList(solrPropsConfig.getCollection(), solrPropsConfig.getRangerCollection().trim());
 
     if (solrPropsConfig.getAliasNameIn() == null || collectionListIn.size() == 0 || solrClient == null) {
@@ -71,7 +71,7 @@ public class SolrAliasDao {
               if (count == collectionListIn.size()) {
                 LOG.info("Setup for alias " + solrPropsConfig.getAliasNameIn() + " is successful. Exiting setup retry thread. " +
                   "Collections=" + collectionListIn);
-                solrSchemaFieldDao.populateSchemaFields(solrClient, solrPropsConfig, solrDaoBase);
+                solrSchemaFieldDao.populateSchemaFields(solrClient, solrPropsConfig);
                 break;
               }
             } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
index ed93b4d..1cbac31 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
@@ -30,15 +30,15 @@ import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
+import javax.inject.Named;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 
-@Component
+@Named
 public class SolrCollectionDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrCollectionDao.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
index 8381948..d9a9464 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
@@ -19,88 +19,91 @@
 
 package org.apache.ambari.logsearch.dao;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
-import org.apache.ambari.logsearch.model.response.BarGraphData;
-import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.util.DateUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrRequest.METHOD;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
+import org.springframework.data.solr.core.DefaultQueryParser;
+import org.springframework.data.solr.core.SolrCallback;
+import org.springframework.data.solr.core.SolrTemplate;
+import org.springframework.data.solr.core.query.SolrDataQuery;
+
+import java.io.IOException;
 
 public abstract class SolrDaoBase {
 
+  private static final Logger LOG = Logger.getLogger(SolrDaoBase.class);
   private static final Logger LOG_PERFORMANCE = Logger.getLogger("org.apache.ambari.logsearch.performance");
 
-  public Map<String, String> schemaFieldNameMap = new HashMap<>();
-  public Map<String, String> schemaFieldTypeMap = new HashMap<>();
-
   private LogType logType;
   
   protected SolrDaoBase(LogType logType) {
     this.logType = logType;
   }
 
-  public QueryResponse process(SolrQuery solrQuery) throws SolrServerException, IOException {
+  public QueryResponse process(SolrQuery solrQuery, String event) {
     if (getSolrClient() != null) {
-      String event = solrQuery.get("event");
+      event = event == null ? solrQuery.get("event") : event;
       solrQuery.remove("event");
-      QueryResponse queryResponse = getSolrClient().query(solrQuery, METHOD.POST);
-      if (event != null && !"/audit/logs/live/count".equalsIgnoreCase(event)) {
-        LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Event :- " + event + " SolrQuery :- " +
+      try {
+        QueryResponse queryResponse = getSolrClient().query(solrQuery, METHOD.POST);
+        if (event != null) {
+          LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Event :- " + event + " SolrQuery :- " +
             solrQuery + "\nQuery Time Execution :- " + queryResponse.getQTime() + " Total Time Elapsed is :- " +
             queryResponse.getElapsedTime());
+        }
+        return queryResponse;
+      } catch (Exception e){
+        LOG.error("Error during solrQuery=" + e);
+        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
       }
-      return queryResponse;
     } else {
       throw RESTErrorUtil.createRESTException("Solr configuration improper for " + logType.getLabel() +" logs",
           MessageEnums.ERROR_SYSTEM);
     }
   }
 
-  @SuppressWarnings("unchecked")
-  public void extractValuesFromBuckets(SimpleOrderedMap<Object> jsonFacetResponse, String outerField, String innerField,
-                                        List<BarGraphData> histogramData) {
-    NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
-    ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get("buckets");
-    for (Object temp : stackBuckets) {
-      BarGraphData vBarGraphData = new BarGraphData();
-
-      SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
-      String name = ((String) level.getVal(0)).toUpperCase();
-      vBarGraphData.setName(name);
+  public QueryResponse process(SolrQuery solrQuery) {
+    return process(solrQuery, null);
+  }
 
-      Collection<NameValueData> vNameValues = new ArrayList<>();
-      vBarGraphData.setDataCount(vNameValues);
-      ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level.get(innerField)).get("buckets");
-      for (Object temp1 : levelBuckets) {
-        SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
-        String value = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
+  public QueryResponse process(SolrDataQuery solrDataQuery) {
+    return process(new DefaultQueryParser().doConstructSolrQuery(solrDataQuery));
+  }
 
-        String count = "" + countValue.getVal(1);
-        NameValueData vNameValue = new NameValueData();
-        vNameValue.setName(value);
-        vNameValue.setValue(count);
-        vNameValues.add(vNameValue);
+  public long count(final SolrDataQuery solrDataQuery) {
+    return getSolrTemplate().execute(new SolrCallback<Long>() {
+      @Override
+      public Long doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
+        SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(solrDataQuery);
+        solrQuery.setStart(0);
+        solrQuery.setRows(0);
+        QueryResponse queryResponse = solrClient.query(solrQuery);
+        long count = solrClient.query(solrQuery).getResults().getNumFound();
+        LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Count SolrQuery :- " +
+          solrQuery + "\nQuery Time Execution :- " + queryResponse.getQTime() + " Total Time Elapsed is :- " +
+          queryResponse.getElapsedTime() + " Count result :- " + count);
+        return count;
       }
-      histogramData.add(vBarGraphData);
-    }
+    });
+  }
+
+  public QueryResponse process(SolrDataQuery solrDataQuery, String event) {
+    return process(new DefaultQueryParser().doConstructSolrQuery(solrDataQuery), event);
   }
 
-  public abstract CloudSolrClient getSolrClient();
+  public CloudSolrClient getSolrClient() {
+    return (CloudSolrClient) getSolrTemplate().getSolrClient();
+  }
+
+  public abstract SolrTemplate getSolrTemplate();
+
+  public abstract SolrSchemaFieldDao getSolrSchemaFieldDao();
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
index b6764d0..f16dc41 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
@@ -33,16 +33,12 @@ import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-@Component
-@Scope(value = "prototype")
 public class SolrSchemaFieldDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrSchemaFieldDao.class);
@@ -52,11 +48,13 @@ public class SolrSchemaFieldDao {
 
   private boolean populateFieldsThreadActive = false;
 
+  private Map<String, String> schemaFieldNameMap = new HashMap<>();
+  private Map<String, String> schemaFieldTypeMap = new HashMap<>();
+
   @Inject
   private SolrUserPropsConfig solrUserPropsConfig;
 
-  public void populateSchemaFields(final CloudSolrClient solrClient, final SolrPropsConfig solrPropsConfig,
-                                   final SolrDaoBase solrDao) {
+  public void populateSchemaFields(final CloudSolrClient solrClient, final SolrPropsConfig solrPropsConfig) {
     if (!populateFieldsThreadActive) {
       populateFieldsThreadActive = true;
       LOG.info("Creating thread to populated fields for collection=" + solrPropsConfig.getCollection());
@@ -69,7 +67,7 @@ public class SolrSchemaFieldDao {
             try {
               Thread.sleep(SETUP_RETRY_SECOND * 1000);
               retryCount++;
-              boolean _result = _populateSchemaFields(solrClient, solrPropsConfig, solrDao);
+              boolean _result = _populateSchemaFields(solrClient, solrPropsConfig);
               if (_result) {
                 LOG.info("Populate fields for collection " + solrPropsConfig.getCollection() + " is success, Update it after " +
                   SETUP_UPDATE_SECOND + " sec");
@@ -94,7 +92,7 @@ public class SolrSchemaFieldDao {
   /**
    * Called from the thread. Don't call this directly
    */
-  private boolean _populateSchemaFields(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig, SolrDaoBase solrDao) {
+  private boolean _populateSchemaFields(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig) {
     SolrRequest<SchemaResponse> request = new SchemaRequest();
     request.setMethod(SolrRequest.METHOD.GET);
     request.setPath("/schema");
@@ -109,7 +107,7 @@ public class SolrSchemaFieldDao {
       }
 
       if (namedList != null) {
-        extractSchemaFieldsName(namedList.toString(), solrDao.schemaFieldNameMap, solrDao.schemaFieldTypeMap);
+        extractSchemaFieldsName(namedList.toString(), schemaFieldNameMap, schemaFieldTypeMap);
         return true;
       }
     }
@@ -156,4 +154,12 @@ public class SolrSchemaFieldDao {
       LOG.error(e + "Credentials not specified in logsearch.properties " + MessageEnums.ERROR_SYSTEM);
     }
   }
+
+  public Map<String, String> getSchemaFieldTypeMap() {
+    return schemaFieldTypeMap;
+  }
+
+  public Map<String, String> getSchemaFieldNameMap() {
+    return schemaFieldNameMap;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
index 88c4577..d650bb7 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
@@ -28,14 +28,15 @@ import java.util.List;
 import java.util.Scanner;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
 import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrUserPropsConfig;
 import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.response.UpdateResponse;
 import org.apache.solr.common.SolrDocument;
@@ -47,15 +48,12 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import com.google.gson.JsonParseException;
 
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
-@Component
+@Named
 public class UserConfigSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(UserConfigSolrDao.class);
@@ -69,10 +67,11 @@ public class UserConfigSolrDao extends SolrDaoBase {
   private SolrCollectionDao solrCollectionDao;
 
   @Inject
+  @Named("serviceSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   @Inject
-  @Qualifier("userConfigSolrTemplate")
+  @Named("userConfigSolrTemplate")
   private SolrTemplate userConfigSolrTemplate;
 
   public UserConfigSolrDao() {
@@ -80,11 +79,10 @@ public class UserConfigSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) userConfigSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return userConfigSolrTemplate;
   }
 
-
   @PostConstruct
   public void postConstructor() {
     String solrUrl = solrUserConfig.getSolrUrl();
@@ -94,7 +92,7 @@ public class UserConfigSolrDao extends SolrDaoBase {
     try {
       solrCollectionDao.checkSolrStatus(getSolrClient());
       solrCollectionDao.setupCollections(getSolrClient(), solrUserConfig);
-      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrUserConfig, this);
+      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrUserConfig);
       intializeLogFeederFilter();
 
     } catch (Exception e) {
@@ -201,6 +199,11 @@ public class UserConfigSolrDao extends SolrDaoBase {
     return logfeederFilterWrapper;
   }
 
+  @Override
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
+  }
+
   private String getHadoopServiceConfigJSON() {
     StringBuilder result = new StringBuilder("");
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
index 0df2ca3..e6f5103 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
@@ -44,6 +44,7 @@ public class DocConstants {
     public static final String IS_LAST_PAGE_D = "Show last page (true/false)";
     public static final String FIELD_D = "Get values for particular field";
     public static final String FORMAT_D = "File Export format, can be 'txt' or 'json'";
+    public static final String TOP = "Number that defines how many top element you would like to see.";
   }
 
   public class AuditOperationDescriptions {
@@ -51,11 +52,7 @@ public class DocConstants {
     public static final String GET_AUDIT_LOGS_OD = "Get the list of logs details";
     public static final String GET_AUDIT_COMPONENTS_OD = "Get the list of audit components currently active or having data in Solr";
     public static final String GET_AUDIT_LINE_GRAPH_DATA_OD = "Get the data required for line graph";
-    public static final String GET_TOP_AUDIT_USERS_OD = "Get the top audit users having maximum access";
-    public static final String GET_TOP_AUDIT_RESOURCES_OD = "Get the top audit resources having maximum access";
-    public static final String GET_LIVE_LOGS_COUNT_OD = "not required";
-    public static final String GET_REQUEST_USER_LINE_GRAPH_OD = "not required";
-    public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
+    public static final String GET_TOP_AUDIT_RESOURCES_OD = "Get the top audit resource count (grouped by type)";
     public static final String EXPORT_USER_TALBE_TO_TEXT_FILE_OD = "Export the tables shown on Audit tab";
     public static final String GET_SERVICE_LOAD_OD = "The graph for showing the top users accessing the services";
   }
@@ -64,7 +61,6 @@ public class DocConstants {
     public static final String LEVEL_D = "filter for log level";
     public static final String BUNDLE_ID = "filter for host";
     public static final String FILE_NAME_D = "File name filter which is supported from browser url";
-    public static final String DATE_RANGE_LABEL_D = "Date range label (e.g.: Today)";
     public static final String HOST_NAME_D = "Host name filter which is supported from browser url";
     public static final String COMPONENT_NAME_D = "Component name filter which is supported from browser url";
     public static final String FIND_D = "Finding particular text on subsequent pages in case of table view with pagination";
@@ -72,7 +68,6 @@ public class DocConstants {
     public static final String KEYWORD_TYPE_D = "Serching the find param value in previous or next in paginated table";
     public static final String TOKEN_D = "unique number used along with FIND_D. The request can be canceled using this token";
     public static final String SOURCE_LOG_ID_D = "fetch the record set having that log Id";
-    public static final String G_MUST_NOT_D = "not required";
     public static final String NUMBER_ROWS_D = "Getting rows after particular log entry - used in 'Preview' option";
     public static final String SCROLL_TYPE_D = "Used in 'Preview' feature for getting records 'after' or 'before'";
     public static final String UTC_OFFSET_D = "timezone offset";
@@ -86,18 +81,15 @@ public class DocConstants {
     public static final String GET_LOG_LEVELS_COUNT_OD = "Get Log levels with their counts";
     public static final String GET_COMPONENTS_COUNT_OD = "Get components with their counts";
     public static final String GET_HOSTS_COUNT_OD = "Get hosts with their counts";
-    public static final String GET_TREE_EXTENSION_OD = "Get host and compoenets hierarchy";
+    public static final String GET_TREE_EXTENSION_OD = "Get host and compoenets hierarchy with log counts";
     public static final String GET_HISTOGRAM_DATA_OD = "Get data for histogram";
-    public static final String CANCEL_FIND_REQUEST_OD = "Cancel the FIND_D param request using TOKEN_D";
     public static final String EXPORT_TO_TEXT_FILE_OD = "Export the table data in file";
     public static final String GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD = "Get components with log level distribution count";
-    public static final String GET_EXTREME_DATES_FOR_BUNDLE_ID_OD = "Get the start and end time of particular bundle_id";
-    public static final String GET_SERVICE_LOGS_FIELD_NAME_OD = "Get service logs schema fields name (Human readable)";
-    public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
-    public static final String GET_AFTER_BEFORE_LOGS_OD = "Preview feature data";
+    public static final String GET_ANY_GRAPH_COUNT_DATA_OD = "Get the data generic enough to use for graph plots (yAzis is always count)";
     public static final String GET_HOST_LIST_BY_COMPONENT_OD = "Get host list of components";
     public static final String GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD = "Get service logs schema fields";
     public static final String GET_HADOOP_SERVICE_CONFIG_JSON_OD = "Get the json having meta data of services supported by logsearch";
+    public static final String GET_AFTER_BEFORE_LOGS_OD = "Preview feature data";
   }
 
   public class PublicOperationDescriptions {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
index 287ff6c..85b5fda 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
@@ -19,324 +19,405 @@
 
 package org.apache.ambari.logsearch.graph;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.MessageEnums;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import org.apache.ambari.logsearch.model.response.BarGraphData;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.CountData;
+import org.apache.ambari.logsearch.model.response.CountDataListResponse;
+import org.apache.ambari.logsearch.model.response.GraphData;
+import org.apache.ambari.logsearch.model.response.GraphDataListResponse;
 import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.query.QueryGeneration;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
+import org.apache.ambari.logsearch.model.response.NodeData;
+import org.apache.ambari.logsearch.model.response.NodeListResponse;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.response.FacetField;
 import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.solr.client.solrj.response.PivotField;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.response.RangeFacet;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.stereotype.Component;
+import org.apache.solr.common.util.NamedList;
 
-import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
-public class GraphDataGenerator extends GraphDataGeneratorBase {
+@Named
+public class GraphDataGenerator {
 
-  private static final Logger logger = Logger.getLogger(GraphDataGenerator.class);
+  public BarGraphDataListResponse generateBarGraphDataResponseWithRanges(QueryResponse response, String typeField, boolean typeUppercase) {
+    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+    if (response == null) {
+      return dataList;
+    }
+    NamedList<List<PivotField>> facetPivotResponse = response.getFacetPivot();
+    if (response.getFacetPivot() == null) {
+      return dataList;
+    }
+    List<PivotField> pivotFields = facetPivotResponse.get(typeField);
+    for (int pivotIndex = 0; pivotIndex < pivotFields.size(); pivotIndex++) {
+      PivotField pivotField = facetPivotResponse.get(typeField).get(pivotIndex);
+      List<NameValueData> nameValues = generateNameValueDataList(pivotField.getFacetRanges());
+      BarGraphData barGraphData = new BarGraphData();
+      barGraphData.setDataCount(nameValues);
+      String typeValue = typeUppercase ? StringUtils.upperCase(pivotField.getValue().toString()) : pivotField.getValue().toString();
+      barGraphData.setName(typeValue);
+      dataList.getGraphData().add(barGraphData);
+    }
+    return dataList;
+  }
 
-  @Inject
-  private QueryGeneration queryGenerator;
+  public BarGraphDataListResponse generateSecondLevelBarGraphDataResponse(QueryResponse response, int val) {
+    BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
+    NamedList<List<PivotField>> pivotFieldNameList = response.getFacetPivot();
+    if (pivotFieldNameList == null) {
+      return barGraphDataListResponse;
+    }
+    List<PivotField> pivotFields = pivotFieldNameList.getVal(val);
+    List<BarGraphData> barGraphDataList = new ArrayList<>();
+    for (PivotField pivotField : pivotFields) {
+      BarGraphData barGraphData = new BarGraphData();
+      barGraphData.setName(String.valueOf(pivotField.getValue()));
+      List<PivotField> secondLevelPivotFields = pivotField.getPivot();
+      List<NameValueData> nameValueDataList = new ArrayList<>();
+      for (PivotField sPivotField : secondLevelPivotFields) {
+        NameValueData nvD = new NameValueData();
+        nvD.setName(String.valueOf(sPivotField.getValue()));
+        nvD.setValue(String.valueOf(sPivotField.getCount()));
+        nameValueDataList.add(nvD);
+      }
+      barGraphData.setDataCount(nameValueDataList);
+      barGraphDataList.add(barGraphData);
+    }
+    barGraphDataListResponse.setGraphData(barGraphDataList);
+    return barGraphDataListResponse;
+  }
 
-  public BarGraphDataListResponse getAnyGraphData(SearchCriteria searchCriteria, SolrDaoBase solrDaoBase, SolrQuery solrQuery) {
-    // X axis credentials
-    String xAxisField = (String) searchCriteria.getParamValue("xAxis");
-    String stackField = (String) searchCriteria.getParamValue("stackBy");
-    String from = (String) searchCriteria.getParamValue("from");
-    String to = (String) searchCriteria.getParamValue("to");
-    String unit = (String) searchCriteria.getParamValue("unit");
-    String typeXAxis = solrDaoBase.schemaFieldNameMap.get(xAxisField);
-    typeXAxis = (StringUtils.isBlank(typeXAxis)) ? "string" : typeXAxis;
+  public BarGraphDataListResponse generateBarGraphFromFieldFacet(QueryResponse response, String facetField) {
+    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+    Collection<BarGraphData> vaDatas = new ArrayList<>();
+    dataList.setGraphData(vaDatas);
+    if (response == null) {
+      return dataList;
+    }
+    FacetField facetFieldObj = response.getFacetField(facetField);
+    if (facetFieldObj == null) {
+      return dataList;
+    }
+
+    List<Count> counts = facetFieldObj.getValues();
+    if (counts == null) {
+      return dataList;
+    }
+    for (Count cnt : counts) {
+      List<NameValueData> valueList = new ArrayList<>();
+      BarGraphData vBarGraphData = new BarGraphData();
+      vaDatas.add(vBarGraphData);
+      NameValueData vNameValue = new NameValueData();
+      vNameValue.setName(cnt.getName());
+      vBarGraphData.setName(cnt.getName().toUpperCase());
+      vNameValue.setValue("" + cnt.getCount());
+      valueList.add(vNameValue);
+      vBarGraphData.setDataCount(valueList);
+    }
+    return dataList;
+  }
+
+  public List<NameValueData> generateNameValueDataList(List<RangeFacet> rangeFacet) {
+    List<NameValueData> nameValues = new ArrayList<>();
+    if (rangeFacet == null) {
+      return nameValues;
+    }
+    RangeFacet range = rangeFacet.get(0);
 
-    // Y axis credentials
-    String yAxisField = (String) searchCriteria.getParamValue("yAxis");
-    // add updated typeXAxis as a type parameter
-    searchCriteria.addParam("type", typeXAxis);
-    String fieldTime = (String) searchCriteria.getParamValue("fieldTime");
-    // decide graph type based on user request parameter
-    GraphType garphType = getGraphType(searchCriteria);
-    switch (garphType) {
-    case NORMAL_GRAPH:
-      return normalGraph(xAxisField, yAxisField, from, to, solrDaoBase, typeXAxis, fieldTime, solrQuery);
-    case RANGE_NON_STACK_GRAPH:
-      return rangeNonStackGraph(xAxisField, yAxisField, from, to, unit, solrDaoBase, typeXAxis, fieldTime, solrQuery);
-    case NON_RANGE_STACK_GRAPH:
-      return nonRangeStackGraph(xAxisField, yAxisField, stackField, from, to, solrDaoBase, typeXAxis, fieldTime, solrQuery);
-    case RANGE_STACK_GRAPH:
-      return rangeStackGraph(xAxisField, stackField, from, to, unit, solrDaoBase, solrQuery);
-    default:
-      logger.warn("Invalid graph type :" + garphType.name());
-      return null;
+    if (range == null) {
+      return nameValues;
+    }
+    List<RangeFacet.Count> listCount = range.getCounts();
+    for (RangeFacet.Count cnt : listCount) {
+      NameValueData nameValue = new NameValueData();
+      nameValue.setName(String.valueOf(cnt.getValue()));
+      nameValue.setValue(String.valueOf(cnt.getCount()));
+      nameValues.add(nameValue);
     }
+    return nameValues;
   }
 
-  private GraphType getGraphType(SearchCriteria searchCriteria) {
-    // default graph type is unknown
-    GraphType graphType = GraphType.UNKNOWN;
-    // X axis credentials
-    String xAxisField = (String) searchCriteria.getParamValue("xAxis");
-    String stackField = (String) searchCriteria.getParamValue("stackBy");
-    String from = (String) searchCriteria.getParamValue("from");
-    String to = (String) searchCriteria.getParamValue("to");
-    String xType = (String) searchCriteria.getParamValue("type");
-    if (xType != null) {
-      // Y axis credentials
-      String yAxisField = (String) searchCriteria.getParamValue("yAxis");
-      if (StringUtils.isBlank(xAxisField) || StringUtils.isBlank(yAxisField)) {
-        graphType = GraphType.UNKNOWN;
-      } else if (StringUtils.isBlank(stackField) && !StringUtils.isBlank(to) && !StringUtils.isBlank(from)
-          && !(xType.contains("date") || xType.contains("time"))) {
-        graphType = GraphType.NORMAL_GRAPH;
-      } else if (StringUtils.isBlank(stackField) && !StringUtils.isBlank(to) && !StringUtils.isBlank(from)
-          && (xType.contains("date") || xType.contains("time"))) {
-        graphType = GraphType.RANGE_NON_STACK_GRAPH;
-      } else if (!StringUtils.isBlank(stackField) && !StringUtils.isBlank(to) && !StringUtils.isBlank(from)
-          && !(xType.contains("date") || xType.contains("time"))) {
-        graphType = GraphType.NON_RANGE_STACK_GRAPH;
-      } else if (!StringUtils.isBlank(stackField) && !StringUtils.isBlank(to) && !StringUtils.isBlank(from)
-          && (xType.contains("date") || xType.contains("time"))) {
-        graphType = GraphType.RANGE_STACK_GRAPH;
+  public List<Count> generateCount(QueryResponse response) {
+    List<Count> counts = new ArrayList<>();
+    List<FacetField> facetFields = null;
+    FacetField facetField = null;
+    if (response == null) {
+      return counts;
+    }
+
+    facetFields = response.getFacetFields();
+    if (facetFields == null) {
+      return counts;
+    }
+    if (!facetFields.isEmpty()) {
+      facetField = facetFields.get(0);
+    }
+    if (facetField != null) {
+      counts = facetField.getValues();
+    }
+    return counts;
+  }
+
+  public BarGraphDataListResponse getGraphDataWithDefaults(QueryResponse queryResponse, String field, String[] defaults) {
+    BarGraphDataListResponse response = new BarGraphDataListResponse();
+    BarGraphData barGraphData = new BarGraphData();
+    List<NameValueData> nameValues = generateLevelCountData(queryResponse, defaults);
+    barGraphData.setName(field);
+    barGraphData.setDataCount(nameValues);
+    response.setGraphData(Lists.newArrayList(barGraphData));
+    return response;
+  }
+
+  public NameValueDataListResponse getNameValueDataListResponseWithDefaults(QueryResponse response, String[] defaults) {
+    NameValueDataListResponse result = new NameValueDataListResponse();
+    result.setvNameValues(generateLevelCountData(response, defaults));
+    return result;
+  }
+
+  public NodeListResponse generateServiceNodeTreeFromFacetResponse(QueryResponse queryResponse,
+                                                                   String firstHierarchy, String secondHierarchy,
+                                                                   String firstType, String secondType) {
+    NodeListResponse response = new NodeListResponse();
+    if (queryResponse == null) {
+      return response;
+    }
+    NamedList<List<PivotField>> namedPivotFieldList = queryResponse.getFacetPivot();
+    List<PivotField> firstLevelPivots = namedPivotFieldList.get(firstHierarchy);
+    List<PivotField> secondLevelPivots = namedPivotFieldList.get(secondHierarchy);
+    if (!CollectionUtils.isNotEmpty(firstLevelPivots) || !CollectionUtils.isNotEmpty(secondLevelPivots)) {
+      return response;
+    }
+    List<NodeData> nodeDataList = buidTreeData(firstLevelPivots, secondLevelPivots, firstType, secondType);
+    response.setvNodeList(nodeDataList);
+    return response;
+  }
+
+  public NodeListResponse generateOneLevelServiceNodeTree(QueryResponse queryResponse, String componentLevelHirachy) {
+    NodeListResponse response = new NodeListResponse();
+    List<NodeData> datatList = new ArrayList<>();
+    List<List<PivotField>> listPivotField = new ArrayList<>();
+    NamedList<List<PivotField>> namedList = queryResponse.getFacetPivot();
+    if (namedList != null) {
+      listPivotField = namedList.getAll(componentLevelHirachy);
+    }
+    List<PivotField> secondHirarchicalPivotFields = null;
+    if (listPivotField == null || listPivotField.isEmpty()) {
+      return response;
+    } else {
+      secondHirarchicalPivotFields = listPivotField.get(0);
+    }
+    for (PivotField singlePivotField : secondHirarchicalPivotFields) {
+      if (singlePivotField != null) {
+        NodeData comp = new NodeData();
+        comp.setName("" + singlePivotField.getValue());
+        List<PivotField> levelList = singlePivotField.getPivot();
+        List<NameValueData> levelCountList = new ArrayList<>();
+        comp.setLogLevelCount(levelCountList);
+        if (levelList != null) {
+          for (PivotField levelPivot : levelList) {
+            NameValueData level = new NameValueData();
+            level.setName(("" + levelPivot.getValue()).toUpperCase());
+            level.setValue("" + levelPivot.getCount());
+            levelCountList.add(level);
+          }
+        }
+        datatList.add(comp);
       }
     }
-    return graphType;
+    response.setvNodeList(datatList);
+    return response;
   }
 
-  @SuppressWarnings("unchecked")
-  private BarGraphDataListResponse normalGraph(String xAxisField, String yAxisField, String from, String to, SolrDaoBase solrDaoBase,
-      String typeXAxis, String fieldTime, SolrQuery solrQuery) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    Collection<BarGraphData> vBarGraphDatas = new ArrayList<BarGraphData>();
-    BarGraphData vBarGraphData = new BarGraphData();
-    Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
-    SolrUtil.setMainQuery(solrQuery, null);
-    queryGenerator.setSingleIncludeFilter(solrQuery, fieldTime, "[" + from + " TO " + to + "]");
-    if (typeXAxis.contains("string") || typeXAxis.contains("key_lower_case") || typeXAxis.contains("text")) {
-      SolrUtil.setFacetField(solrQuery, xAxisField);
-      try {
-        QueryResponse response = solrDaoBase.process(solrQuery);
-        if (response != null && response.getResults() != null) {
-          long count = response.getResults().getNumFound();
-          if (count > 0) {
-            FacetField facetField = response.getFacetField(xAxisField);
-            if (facetField != null) {
-              List<Count> countValues = facetField.getValues();
-              if (countValues != null) {
-                for (Count countValue : countValues) {
-                  if (countValue != null) {
-                    NameValueData vNameValue = new NameValueData();
-                    vNameValue.setName(countValue.getName());
-                    vNameValue.setValue("" + countValue.getCount());
-                    vNameValues.add(vNameValue);
-                  }
-                }
+  private List<NodeData> buidTreeData(List<PivotField> firstHirarchicalPivotFields,
+                                      List<PivotField> secondHirarchicalPivotFields,
+                                      String firstPriority, String secondPriority) {
+    List<NodeData> extensionTree = new ArrayList<>();
+    if (firstHirarchicalPivotFields != null) {
+      for (PivotField pivotHost : firstHirarchicalPivotFields) {
+        if (pivotHost != null) {
+          NodeData hostNode = new NodeData();
+          String name = (pivotHost.getValue() == null ? "" : "" + pivotHost.getValue());
+          String value = "" + pivotHost.getCount();
+          if (!StringUtils.isBlank(name)) {
+            hostNode.setName(name);
+          }
+          if (!StringUtils.isBlank(value)) {
+            hostNode.setValue(value);
+          }
+          if (!StringUtils.isBlank(firstPriority)) {
+            hostNode.setType(firstPriority);
+          }
+
+          hostNode.setParent(true);
+          hostNode.setRoot(true);
+          PivotField hostPivot = null;
+          for (PivotField searchHost : secondHirarchicalPivotFields) {
+            if (!StringUtils.isBlank(hostNode.getName())
+              && hostNode.getName().equals(searchHost.getValue())) {
+              hostPivot = searchHost;
+              break;
+            }
+          }
+          List<PivotField> pivotLevelHost = hostPivot == null? null : hostPivot.getPivot();
+          if (pivotLevelHost != null) {
+            Collection<NameValueData> logLevelCount = new ArrayList<>();
+            for (PivotField pivotLevel : pivotLevelHost) {
+              if (pivotLevel != null) {
+                NameValueData vnameValue = new NameValueData();
+                String levelName = (pivotLevel.getValue() == null ? "" : "" + pivotLevel.getValue());
+                vnameValue.setName(levelName.toUpperCase());
+                vnameValue.setValue("" + pivotLevel.getCount());
+                logLevelCount.add(vnameValue);
               }
-              vBarGraphData.setName(xAxisField);
-              vBarGraphDatas.add(vBarGraphData);
-              dataList.setGraphData(vBarGraphDatas);
             }
+            hostNode.setLogLevelCount(logLevelCount);
           }
-        }
-        if (xAxisField.equalsIgnoreCase(LogSearchConstants.SOLR_LEVEL)) {
-          Collection<NameValueData> sortedVNameValues = new ArrayList<NameValueData>();
-          for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
-            NameValueData value = new NameValueData();
-            value.setName(level);
-            String val = "0";
-            for (NameValueData valueLevel : vNameValues) {
-              if (valueLevel.getName().equalsIgnoreCase(level)) {
-                val = valueLevel.getValue();
-                break;
+          List<PivotField> pivotComponents = pivotHost.getPivot();
+          if (pivotComponents != null) {
+            Collection<NodeData> componentNodes = new ArrayList<>();
+            for (PivotField pivotComp : pivotComponents) {
+              if (pivotComp != null) {
+                NodeData compNode = new NodeData();
+                String compName = (pivotComp.getValue() == null ? "" : "" + pivotComp.getValue());
+                compNode.setName(compName);
+                if (!StringUtils.isBlank(secondPriority)) {
+                  compNode.setType(secondPriority);
+                }
+                compNode.setValue("" + pivotComp.getCount());
+                compNode.setParent(false);
+                compNode.setRoot(false);
+                List<PivotField> pivotLevels = pivotComp.getPivot();
+                if (pivotLevels != null) {
+                  Collection<NameValueData> logLevelCount = new ArrayList<>();
+                  for (PivotField pivotLevel : pivotLevels) {
+                    if (pivotLevel != null) {
+                      NameValueData vnameValue = new NameValueData();
+                      String compLevel = pivotLevel.getValue() == null ? "" : "" + pivotLevel.getValue();
+                      vnameValue.setName((compLevel).toUpperCase());
+
+                      vnameValue.setValue("" + pivotLevel.getCount());
+                      logLevelCount.add(vnameValue);
+                    }
+                  }
+                  compNode.setLogLevelCount(logLevelCount);
+                }
+                componentNodes.add(compNode);
               }
             }
-            value.setValue(val);
-            sortedVNameValues.add(value);
+            hostNode.setChilds(componentNodes);
           }
-          vBarGraphData.setDataCount(sortedVNameValues);
-        } else {
-          vBarGraphData.setDataCount(vNameValues);
-        }
-        return dataList;
-      } catch (SolrException | SolrServerException | IOException e) {
-        String query = solrQuery != null ? solrQuery.toQueryString() : "";
-        logger.error("Got exception for solr query :" + query, e.getCause());
-      }
-    } else {
-      SolrUtil.setRowCount(solrQuery, 0);
-      String yAxis = yAxisField.contains("count") ? "sum" : yAxisField;
-      String jsonQuery = queryGenerator.buildJSONFacetAggregatedFuncitonQuery(yAxis, xAxisField);
-      SolrUtil.setJSONFacet(solrQuery, jsonQuery);
-      try {
-        QueryResponse response = solrDaoBase.process(solrQuery);
-        SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-        if (jsonFacetResponse.toString().equals("{count=0}")) {
-          return dataList;
+          extensionTree.add(hostNode);
         }
-        NameValueData value = new NameValueData();
-        String sum = (String) jsonFacetResponse.getVal(1);
-        value.setName(xAxisField);
-        value.setValue(sum != null ? sum.substring(0, sum.indexOf(".")) : "");
-        vNameValues.add(value);
-        vBarGraphData.setDataCount(vNameValues);
-        vBarGraphData.setName(xAxisField);
-        vBarGraphDatas.add(vBarGraphData);
-        dataList.setGraphData(vBarGraphDatas);
-        return dataList;
-      } catch (SolrException | SolrServerException | IOException e) {
-        String query = solrQuery != null ? solrQuery.toQueryString() : "";
-        logger.error("Got exception for solr query :" + query, e.getCause());
       }
     }
-    return null;
+
+    return extensionTree;
   }
 
-  @SuppressWarnings("unchecked")
-  private BarGraphDataListResponse nonRangeStackGraph(String xAxisField, String yAxisField, String stackField, String from, String to,
-      SolrDaoBase solrDaoBase, String typeXAxis, String fieldTime, SolrQuery solrQuery) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    Collection<BarGraphData> vGraphData = new ArrayList<BarGraphData>();
-    String mainQuery = queryGenerator.buildInclusiveRangeFilterQuery(fieldTime, from, to);
-    SolrUtil.setMainQuery(solrQuery, mainQuery);
-    SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-    String jsonQuery = "";
-    if (SolrUtil.isSolrFieldNumber(typeXAxis,solrDaoBase)) {
-      String function = (yAxisField.contains("count")) ? "sum" : yAxisField;
-      jsonQuery = queryGenerator.buidlJSONFacetRangeQueryForNumber(stackField, xAxisField, function);
-    } else {
-      jsonQuery = queryGenerator.buildJsonFacetTermsRangeQuery(stackField, xAxisField);
-    }
-    try {
-      SolrUtil.setJSONFacet(solrQuery, jsonQuery);
-      dataList.setGraphData(vGraphData);
-      QueryResponse response = solrDaoBase.process(solrQuery);
-      if (response == null) {
-        response = new QueryResponse();
-      }
-      Long count = response.getResults().getNumFound();
-      if (count <= 0) {
-        return dataList;
-      }
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-      if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
-        return dataList;
-      }
-      extractNonRangeStackValuesFromBucket(jsonFacetResponse, stackField, vGraphData, typeXAxis);
-      if (LogSearchConstants.SOLR_LEVEL.equalsIgnoreCase(stackField) && LogSearchConstants.SOLR_LEVEL.equalsIgnoreCase(xAxisField)) {
-        Collection<BarGraphData> levelVGraphData = dataList.getGraphData();
-        for (BarGraphData graphData : levelVGraphData) {
-          Collection<NameValueData> valueList = graphData.getDataCount();
-          Collection<NameValueData> valueListSorted = new ArrayList<NameValueData>();
-          for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
-            String val = "0";
-            for (NameValueData value : valueList) {
-              if (value.getName().equalsIgnoreCase(level)) {
-                val = value.getValue();
-                break;
-              }
-            }
-            NameValueData v1 = new NameValueData();
-            v1.setName(level.toUpperCase());
-            v1.setValue(val);
-            valueListSorted.add(v1);
-          }
-          graphData.setDataCount(valueListSorted);
-        }
+  private List<NameValueData> generateLevelCountData(QueryResponse queryResponse, String[] defaults) {
+    List<NameValueData> nameValues = Lists.newLinkedList();
+    Map<String, NameValueData> linkedMap = Maps.newLinkedHashMap();
+    List<Count> counts = generateCount(queryResponse);
+    if (!CollectionUtils.isNotEmpty(counts)) {
+      return nameValues;
+    }
+    for (String defaultValue : defaults) {
+      NameValueData nameValue = new NameValueData();
+      nameValue.setName(defaultValue);
+      nameValue.setValue("0");
+      linkedMap.put(defaultValue, nameValue);
+    }
+    for (Count count : counts) {
+      if (!linkedMap.containsKey(count.getName())) {
+        NameValueData nameValue = new NameValueData();
+        String name = count.getName().toUpperCase();
+        nameValue.setName(name);
+        nameValue.setValue(String.valueOf(count.getCount()));
+        linkedMap.put(name, nameValue);
       }
-      return dataList;
-    } catch (SolrException | IOException | SolrServerException e) {
-      String query = solrQuery != null ? solrQuery.toQueryString() : "";
-      logger.error("Got exception for solr query :" + query, e.getCause());
-      throw RESTErrorUtil.createRESTException(MessageEnums.DATA_NOT_FOUND.getMessage().getMessage(), MessageEnums.DATA_NOT_FOUND);
     }
+
+    for (Map.Entry<String, NameValueData> nameValueDataEntry : linkedMap.entrySet()) {
+      nameValues.add(nameValueDataEntry.getValue());
+    }
+    return nameValues;
   }
 
-  @SuppressWarnings("unchecked")
-  private BarGraphDataListResponse rangeNonStackGraph(String xAxisField, String yAxisField, String from, String to, String unit,
-      SolrDaoBase solrDaoBase, String typeXAxis, String fieldTime, SolrQuery solrQuery) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    Collection<BarGraphData> vBarGraphDatas = new ArrayList<BarGraphData>();
-    BarGraphData vBarGraphData = new BarGraphData();
-    Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
-    SolrUtil.setMainQuery(solrQuery, null);
-    if (SolrUtil.isSolrFieldNumber(typeXAxis,solrDaoBase)) {
-      queryGenerator.setSingleRangeFilter(solrQuery, fieldTime, from, to);
-      return normalGraph(xAxisField, yAxisField, from, to, solrDaoBase, typeXAxis, fieldTime, solrQuery);
-    } else {
-      try {
-        SolrUtil.setFacetRange(solrQuery, xAxisField, from, to, unit);
-        QueryResponse response = solrDaoBase.process(solrQuery);
-        if (response != null) {
-          Long count = response.getResults().getNumFound();
-          if (count > 0) {
-            @SuppressWarnings("rawtypes")
-            List<RangeFacet> rangeFacet = response.getFacetRanges();
-            if (rangeFacet != null && rangeFacet.size() > 0) {
-              List<RangeFacet.Count> listCount = rangeFacet.get(0).getCounts();
-              if (listCount != null) {
-                for (RangeFacet.Count cnt : listCount) {
-                  NameValueData vNameValue = new NameValueData();
-                  vNameValue.setName(cnt.getValue());
-                  vNameValue.setValue("" + cnt.getCount());
-                  vNameValues.add(vNameValue);
-                }
-                vBarGraphData.setDataCount(vNameValues);
-                vBarGraphDatas.add(vBarGraphData);
-                vBarGraphData.setName(xAxisField);
-                dataList.setGraphData(vBarGraphDatas);
-              }
-            }
-          }
-        }
-        return dataList;
-      } catch (SolrException | SolrServerException | IOException e) {
-        logger.error("Got exception for solr query :" + solrQuery, e.getCause());
+  public CountDataListResponse generateCountResponseByField(QueryResponse response, String field) {
+    CountDataListResponse collection = new CountDataListResponse();
+    List<CountData> vCounts = new ArrayList<>();
+    if (response == null) {
+      return collection;
+    }
+    FacetField facetFields = response.getFacetField(field);
+    if (facetFields == null) {
+      return collection;
+    }
+    List<Count> fieldList = facetFields.getValues();
+
+    if (fieldList == null) {
+      return collection;
+    }
+
+    for (Count cnt : fieldList) {
+      if (cnt != null) {
+        CountData vCount = new CountData();
+        vCount.setName(cnt.getName());
+        vCount.setCount(cnt.getCount());
+        vCounts.add(vCount);
       }
     }
-    return null;
+    collection.setvCounts(vCounts);
+    return collection;
   }
 
-  @SuppressWarnings("unchecked")
-  private BarGraphDataListResponse rangeStackGraph(String xAxisField, String stackField, String from, String to, String unit,
-      SolrDaoBase solrDaoBase, SolrQuery solrQuery) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
-    SolrUtil.setMainQuery(solrQuery, null);
-    SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-    String jsonHistogramQuery =
-        queryGenerator.buildJSONFacetTermTimeRangeQuery(stackField, xAxisField, from, to, unit).replace("\\", "");
-    try {
-      solrQuery.set("json.facet", jsonHistogramQuery);
-      SolrUtil.setRowCount(solrQuery, 0);
-      QueryResponse response = solrDaoBase.process(solrQuery);
-      if (response != null) {
-        SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-        if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
-          return dataList;
+  public GraphDataListResponse generateSimpleGraphResponse(QueryResponse response, String hierarchy) {
+    GraphDataListResponse graphInfo = new GraphDataListResponse();
+    if (response == null) {
+      return graphInfo;
+    }
+    List<List<PivotField>> hirarchicalPivotField = new ArrayList<List<PivotField>>();
+    List<GraphData> dataList = new ArrayList<>();
+    NamedList<List<PivotField>> namedList = response.getFacetPivot();
+    if (namedList != null) {
+      hirarchicalPivotField = namedList.getAll(hierarchy);
+    }
+    if (!hirarchicalPivotField.isEmpty()) {
+      dataList = buidGraphData(hirarchicalPivotField.get(0));
+    }
+    if (!dataList.isEmpty()) {
+      graphInfo.setGraphData(dataList);
+    }
+
+    return graphInfo;
+  }
+
+  private List<GraphData> buidGraphData(List<PivotField> pivotFields) {
+    List<GraphData> logList = new ArrayList<>();
+    if (pivotFields != null) {
+      for (PivotField pivotField : pivotFields) {
+        if (pivotField != null) {
+          GraphData logLevel = new GraphData();
+          logLevel.setName("" + pivotField.getValue());
+          logLevel.setCount(Long.valueOf(pivotField.getCount()));
+          if (pivotField.getPivot() != null) {
+            logLevel.setDataList(buidGraphData(pivotField.getPivot()));
+          }
+          logList.add(logLevel);
         }
-        extractRangeStackValuesFromBucket(jsonFacetResponse, "x", "y", histogramData);
-        dataList.setGraphData(histogramData);
       }
-      return dataList;
-    } catch (SolrException | IOException | SolrServerException e) {
-      logger.error("Got exception for solr query :" + solrQuery, e.getCause());
     }
-    return null;
+    return logList;
   }
 }


[2/7] ambari git commit: AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTreeRequestFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTreeRequestFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTreeRequestFacetQueryConverter.java
new file mode 100644
index 0000000..e3da5c2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTreeRequestFacetQueryConverter.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogHostComponentRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogTreeRequestFacetQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogHostComponentRequest>{
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogHostComponentRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogHostComponentRequest request) {
+    facetOptions.addFacetOnPivot(HOST, COMPONENT, LEVEL);
+    facetOptions.addFacetOnPivot(HOST, LEVEL);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
deleted file mode 100644
index 2154357..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
-import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceLogTruncatedRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogTruncatedRequest, ServiceLogTruncatedSearchCriteria> {
-
-  @Override
-  public ServiceLogTruncatedSearchCriteria createCriteria(ServiceLogTruncatedRequest request) {
-    ServiceLogTruncatedSearchCriteria criteria = new ServiceLogTruncatedSearchCriteria();
-    criteria.setId(request.getId());
-    criteria.setScrollType(request.getScrollType());
-    criteria.setNumberRows(request.getNumberRows());
-    return criteria;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestQueryConverter.java
new file mode 100644
index 0000000..ff2da1b
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestQueryConverter.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.SimpleQuery;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+public class ServiceLogTruncatedRequestQueryConverter extends AbstractLogRequestQueryConverter<ServiceLogTruncatedRequest, SimpleQuery>{
+
+  private String sequenceId;
+
+  private String logTime;
+
+  @Override
+  public SimpleQuery extendLogQuery(ServiceLogTruncatedRequest request, SimpleQuery query) {
+    addEqualsFilterQuery(query, COMPONENT, request.getComponentName());
+    addEqualsFilterQuery(query, HOST, request.getHostName());
+    String scrollType = request.getScrollType();
+    if (LogSearchConstants.SCROLL_TYPE_BEFORE.equals(scrollType)) {
+      Integer secuenceIdNum = Integer.parseInt(getSequenceId()) - 1;
+      addRangeFilter(query, LOGTIME, null, getLogTime());
+      addRangeFilter(query, SEQUENCE_ID, null, secuenceIdNum.toString());
+    } else if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
+      Integer secuenceIdNum = Integer.parseInt(getSequenceId()) + 1;
+      addRangeFilter(query, LOGTIME, getLogTime(), null);
+      addRangeFilter(query, SEQUENCE_ID, secuenceIdNum.toString(), null);
+    }
+    query.setRows(request.getNumberRows());
+    return query;
+  }
+
+  @Override
+  public Sort sort(ServiceLogTruncatedRequest request) {
+    String scrollType = request.getScrollType();
+    Sort.Direction direction;
+    if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
+      direction = Sort.Direction.ASC;
+    } else {
+      direction = Sort.Direction.DESC;
+    }
+    Sort.Order logtimeSortOrder = new Sort.Order(direction, LOGTIME);
+    Sort.Order secuqnceIdSortOrder = new Sort.Order(direction, SEQUENCE_ID);
+    return new Sort(logtimeSortOrder, secuqnceIdSortOrder);
+  }
+
+  @Override
+  public SimpleQuery createQuery() {
+    return new SimpleQuery();
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  public String getSequenceId() {
+    return sequenceId;
+  }
+
+  public void setSequenceId(String sequenceId) {
+    this.sequenceId = sequenceId;
+  }
+
+  public String getLogTime() {
+    return logTime;
+  }
+
+  public void setLogTime(String logTime) {
+    this.logTime = logTime;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java
deleted file mode 100644
index 1f084fd..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.SimpleQueryRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SimpleQueryRequestConverter extends AbstractConverterAware<SimpleQueryRequest, CommonSearchCriteria> {
-
-  @Override
-  public CommonSearchCriteria convert(SimpleQueryRequest simpleQueryRequest) {
-    CommonSearchCriteria searchCriteria = new CommonSearchCriteria();
-    searchCriteria.addParam("q", simpleQueryRequest.getQuery());
-    return searchCriteria;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/StringFieldFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/StringFieldFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/StringFieldFacetQueryConverter.java
new file mode 100644
index 0000000..068fdb2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/StringFieldFacetQueryConverter.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import javax.inject.Named;
+
+@Named
+public class StringFieldFacetQueryConverter extends AbstractConverterAware<String, SimpleFacetQuery> {
+
+  @Override
+  public SimpleFacetQuery convert(String fieldName) {
+    Criteria criteria = new SimpleStringCriteria("*:*");
+    SimpleFacetQuery facetQuery = new SimpleFacetQuery();
+    facetQuery.addCriteria(criteria);
+    facetQuery.setRows(0);
+    FacetOptions facetOptions = new FacetOptions();
+    facetOptions.setFacetMinCount(1);
+    facetOptions.addFacetOnField(fieldName);
+    facetOptions.setFacetLimit(-1);
+    facetQuery.setFacetOptions(facetOptions);
+    return facetQuery;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java
deleted file mode 100644
index c7f738e..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
-import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class UserExportRequestConverter extends AbstractCommonAuditLogRequestConverter<UserExportRequest, UserExportSearchCriteria> {
-
-  @Override
-  public UserExportSearchCriteria createCriteria(UserExportRequest request) {
-    UserExportSearchCriteria criteria = new UserExportSearchCriteria();
-    criteria.setField(request.getField());
-    criteria.setFormat(request.getFormat());
-    return criteria;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestQueryConverter.java
new file mode 100644
index 0000000..530108a
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestQueryConverter.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_REQUEST_USER;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_RESOURCE;
+
+@Named
+public class UserExportRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<UserExportRequest> {
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, UserExportRequest request) {
+    facetOptions.addFacetOnPivot(AUDIT_REQUEST_USER, AUDIT_COMPONENT);
+    facetOptions.addFacetOnPivot(AUDIT_RESOURCE, AUDIT_COMPONENT);
+  }
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return AUDIT_EVTTIME;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java
deleted file mode 100644
index aa61851..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_FROM;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_STACK_BY;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_TO;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_UNIT;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_X_AXIS;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_Y_AXIS;
-
-public class AnyGraphSearchCriteria extends CommonSearchCriteria {
-
-  public String getxAxis() {
-    return getParam(PARAM_X_AXIS, String.class);
-  }
-
-  public void setxAxis(String xAxis) {
-    addParam(PARAM_X_AXIS, xAxis);
-  }
-
-  public String getyAxis() {
-    return getParam(PARAM_Y_AXIS, String.class);
-  }
-
-  public void setyAxis(String yAxis) {
-    addParam(PARAM_Y_AXIS, yAxis);
-  }
-
-  public String getStackBy() {
-    return getParam(PARAM_STACK_BY, String.class);
-  }
-
-  public void setStackBy(String stackBy) {
-    addParam(PARAM_STACK_BY, stackBy);
-  }
-
-  public String getUnit() {
-    return getParam(PARAM_UNIT, String.class);
-  }
-
-  public void setUnit(String unit) {
-    addParam(PARAM_UNIT, unit);
-  }
-
-  public String getFrom() {
-    return getParam(PARAM_FROM, String.class);
-  }
-
-  public void setFrom(String from) {
-    addParam(PARAM_FROM, from);
-  }
-
-  public String getTo() {
-    return getParam(PARAM_TO, String.class);
-  }
-
-  public void setTo(String to) {
-    addParam(PARAM_TO, to);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java
deleted file mode 100644
index 49304c4..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_UNIT;
-
-public class AuditBarGraphSearchCriteria extends CommonSearchCriteria {
-
-  public void setUnit(String unit) {
-    addParam(PARAM_UNIT, unit);
-  }
-
-  public String getUnit() {
-    return getParam(PARAM_UNIT, String.class);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java
deleted file mode 100644
index 03df3ad..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_IS_LAST_PAGE;
-
-public class AuditLogSearchCriteria extends CommonSearchCriteria {
-
-  public void setLastPage(boolean lastPage) {
-    addParam(PARAM_IS_LAST_PAGE, lastPage);
-  }
-
-  public boolean isLastPage() {
-    return getParam(PARAM_IS_LAST_PAGE, Boolean.class);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java
deleted file mode 100644
index b02c234..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class CommonServiceLogSearchCriteria extends CommonSearchCriteria {
-
-  public String getLevel() {
-    return getParam(SearchCriteriaConstants.PARAM_LEVEL, String.class);
-  }
-
-  public void setLevel(String level) {
-    addParam(SearchCriteriaConstants.PARAM_LEVEL, level);
-  }
-
-  public String getSelectComp() {
-    return getParam(SearchCriteriaConstants.PARAM_SELECT_COMP, String.class);
-  }
-
-  public void setSelectComp(String selectComp) {
-    addParam(SearchCriteriaConstants.PARAM_SELECT_COMP, selectComp);
-  }
-
-  public String getBundleId() {
-    return getParam(SearchCriteriaConstants.PARAM_BUNDLE_ID, String.class);
-  }
-
-  public void setBundleId(String bunldeId) {
-    addParam(SearchCriteriaConstants.PARAM_BUNDLE_ID, bunldeId);
-  }
-
-  public String getFrom() {
-    return getParam(SearchCriteriaConstants.PARAM_FROM ,String.class);
-  }
-
-  public void setFrom(String from) {
-    addParam(SearchCriteriaConstants.PARAM_FROM, from);
-  }
-
-  public String getTo() {
-    return getParam(SearchCriteriaConstants.PARAM_TO ,String.class);
-  }
-
-  public void setTo(String to) {
-    addParam(SearchCriteriaConstants.PARAM_TO, to);
-  }
-
-  public String getHostName() {
-    return getParam(SearchCriteriaConstants.PARAM_HOST_NAME ,String.class);
-  }
-
-  public void setHostName(String hostName) {
-    addParam(SearchCriteriaConstants.PARAM_HOST_NAME, hostName);
-  }
-
-  public String getComponentName() {
-    return getParam(SearchCriteriaConstants.PARAM_COMPONENT_NAME ,String.class);
-  }
-
-  public void setComponentName(String componentName) {
-    addParam(SearchCriteriaConstants.PARAM_COMPONENT_NAME, componentName);
-  }
-
-  public String getFileName() {
-    return getParam(SearchCriteriaConstants.PARAM_FILE_NAME ,String.class);
-  }
-
-  public void setFileName(String fileName) {
-    addParam(SearchCriteriaConstants.PARAM_FILE_NAME, fileName);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java
deleted file mode 100644
index 381b3c2..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_FIELD;
-
-public class FieldAuditBarGraphSearchCriteria extends AuditBarGraphSearchCriteria {
-
-  public String getField() {
-    return getParam(PARAM_FIELD, String.class);
-  }
-
-  public void setField(String field) {
-    addParam(PARAM_FIELD, field);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java
deleted file mode 100644
index 9d5d225..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_FIELD;
-
-public class FieldAuditLogSearchCriteria extends CommonSearchCriteria {
-
-  public String getField() {
-    return getParam(PARAM_FIELD, String.class);
-  }
-
-  public void setField(String field) {
-    addParam(PARAM_FIELD, field);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
deleted file mode 100644
index 0f4bb5a..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.common.Marker;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_STACK_BY;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_UNIT;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_X_AXIS;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_Y_AXIS;
-
-public class ServiceAnyGraphSearchCriteria extends ServiceLogSearchCriteria {
-  public String getxAxis() {
-    return getParam(PARAM_X_AXIS, String.class);
-  }
-
-  public void setxAxis(String xAxis) {
-    addParam(PARAM_X_AXIS, xAxis);
-  }
-
-  public String getyAxis() {
-    return getParam(PARAM_Y_AXIS, String.class);
-  }
-
-  public void setyAxis(String yAxis) {
-    addParam(PARAM_Y_AXIS, yAxis);
-  }
-
-  public String getStackBy() {
-    return getParam(PARAM_STACK_BY, String.class);
-  }
-
-  public void setStackBy(String stackBy) {
-    addParam(PARAM_STACK_BY, stackBy);
-  }
-
-  public String getUnit() {
-    return getParam(PARAM_UNIT, String.class);
-  }
-
-  public void setUnit(String unit) {
-    addParam(PARAM_UNIT, unit);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java
deleted file mode 100644
index d89ab3b..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class ServiceExtremeDatesCriteria extends CommonSearchCriteria {
-
-  public String getBundleId() {
-    return getParam(SearchCriteriaConstants.PARAM_BUNDLE_ID, String.class);
-  }
-
-  public void setBundleId(String bunldeId) {
-    addParam(SearchCriteriaConstants.PARAM_BUNDLE_ID, bunldeId);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
deleted file mode 100644
index 4173bac..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class ServiceGraphSearchCriteria extends ServiceLogSearchCriteria {
-
-  public String getUnit() {
-    return getParam(SearchCriteriaConstants.PARAM_UNIT, String.class);
-  }
-
-  public void setUnit(String unit) {
-    addParam(SearchCriteriaConstants.PARAM_UNIT, unit);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
deleted file mode 100644
index 6c757af..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class ServiceLogExportSearchCriteria extends ServiceLogSearchCriteria {
-
-  public void setFormat(String format) {
-    addParam(SearchCriteriaConstants.PARAM_FORMAT, format);
-  }
-
-  public String getFormat() {
-    return getParam(SearchCriteriaConstants.PARAM_FORMAT, String.class);
-  }
-
-  public void setUtcOffset(String utcOffset) {
-    addParam(SearchCriteriaConstants.PARAM_UTC_OFFSET, utcOffset);
-  }
-
-  public String getUtcOffset() {
-    return getParam(SearchCriteriaConstants.PARAM_UTC_OFFSET, String.class);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
deleted file mode 100644
index e469367..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class ServiceLogSearchCriteria extends CommonServiceLogSearchCriteria {
-
-  public void setKeyword(String keyword) {
-    addParam(SearchCriteriaConstants.PARAM_KEYWORD, keyword);
-  }
-
-  public String getKeyword() {
-    return getParam(SearchCriteriaConstants.PARAM_KEYWORD, String.class);
-  }
-
-  public void setKeywordType(String keywordType) {
-    addParam(SearchCriteriaConstants.PARAM_KEYWORD_TYPE, keywordType);
-  }
-
-  public String getKeywordType() {
-    return getParam(SearchCriteriaConstants.PARAM_KEYWORD_TYPE, String.class);
-  }
-
-  public void setSourceLogId(String sourceLogId) {
-    addParam(SearchCriteriaConstants.PARAM_SOURCE_LOG_ID, sourceLogId);
-  }
-
-  public String getSourceLogId() {
-    return getParam(SearchCriteriaConstants.PARAM_SOURCE_LOG_ID, String.class);
-  }
-
-  public void setToken(String token) {
-    addParam(SearchCriteriaConstants.PARAM_TOKEN, token);
-  }
-
-  public String getToken() {
-    return getParam(SearchCriteriaConstants.PARAM_TOKEN, String.class);
-  }
-
-  public void setLastPage(boolean lastPage) {
-    addParam(SearchCriteriaConstants.PARAM_IS_LAST_PAGE, lastPage);
-  }
-
-  public boolean isLastPage() {
-    return getParam(SearchCriteriaConstants.PARAM_IS_LAST_PAGE, Boolean.class);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
deleted file mode 100644
index 277aeb9..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class ServiceLogTruncatedSearchCriteria extends ServiceLogSearchCriteria {
-
-  public String getId() {
-    return getParam(SearchCriteriaConstants.PARAM_ID, String.class);
-  }
-
-  public void setId(String id) {
-    addParam(SearchCriteriaConstants.PARAM_ID, id);
-  }
-
-  public String getScrollType() {
-    return getParam(SearchCriteriaConstants.PARAM_SCROLL_TYPE, String.class);
-  }
-
-  public void setScrollType(String scrollType) {
-    addParam(SearchCriteriaConstants.PARAM_SCROLL_TYPE, scrollType);
-  }
-
-  public String getNumberRows() {
-    return getParam(SearchCriteriaConstants.PARAM_NUMBER_ROWS, String.class);
-  }
-
-  public void setNumberRows(String numberRows) {
-    addParam(SearchCriteriaConstants.PARAM_NUMBER_ROWS, numberRows);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java
deleted file mode 100644
index 46d13cc..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class UserExportSearchCriteria extends FieldAuditLogSearchCriteria {
-  public void setFormat(String format) {
-    addParam(SearchCriteriaConstants.PARAM_FORMAT, format);
-  }
-
-  public String getFormat() {
-    return getParam(SearchCriteriaConstants.PARAM_FORMAT, String.class);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
index 0bd326e..d5b6525 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
@@ -20,52 +20,39 @@
 package org.apache.ambari.logsearch.rest;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.ws.rs.BeanParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
 
+import freemarker.template.TemplateException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.ambari.logsearch.model.request.impl.AnyGraphRequest;
 import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
-import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest;
-import org.apache.ambari.logsearch.model.request.impl.FieldAuditBarGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
 import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
-import org.apache.ambari.logsearch.model.request.impl.SimpleQueryRequest;
 import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
 import org.apache.ambari.logsearch.model.response.AuditLogResponse;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
 import org.apache.ambari.logsearch.model.response.GroupListResponse;
-import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
-import org.apache.ambari.logsearch.query.model.AnyGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria;
 import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
 import org.apache.ambari.logsearch.manager.AuditLogsManager;
-import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
 import org.springframework.context.annotation.Scope;
-import org.springframework.core.convert.ConversionService;
-import org.springframework.stereotype.Component;
 
 import static org.apache.ambari.logsearch.doc.DocConstants.AuditOperationDescriptions.*;
 
 @Api(value = "audit/logs", description = "Audit log operations")
 @Path("audit/logs")
-@Component
+@Named
 @Scope("request")
 public class AuditLogsResource {
 
   @Inject
   private AuditLogsManager auditLogsManager;
 
-  @Inject
-  private ConversionService conversionService;
-
   @GET
   @Path("/schema/fields")
   @Produces({"application/json"})
@@ -78,15 +65,15 @@ public class AuditLogsResource {
   @Produces({"application/json"})
   @ApiOperation(GET_AUDIT_LOGS_OD)
   public AuditLogResponse getAuditLogs(@BeanParam AuditLogRequest auditLogRequest) {
-    return auditLogsManager.getLogs(conversionService.convert(auditLogRequest, AuditLogSearchCriteria.class));
+    return auditLogsManager.getLogs(auditLogRequest);
   }
 
   @GET
   @Path("/components")
   @Produces({"application/json"})
   @ApiOperation(GET_AUDIT_COMPONENTS_OD)
-  public GroupListResponse getAuditComponents(@BeanParam SimpleQueryRequest request) {
-    return auditLogsManager.getAuditComponents(conversionService.convert(request, CommonSearchCriteria.class));
+  public GroupListResponse getAuditComponents(@BeanParam AuditComponentRequest request) {
+    return auditLogsManager.getAuditComponents(request);
   }
 
   @GET
@@ -94,63 +81,31 @@ public class AuditLogsResource {
   @Produces({"application/json"})
   @ApiOperation(GET_AUDIT_LINE_GRAPH_DATA_OD)
   public BarGraphDataListResponse getAuditBarGraphData(@BeanParam AuditBarGraphRequest request) {
-    return auditLogsManager.getAuditBarGraphData(conversionService.convert(request, AuditBarGraphSearchCriteria.class));
+    return auditLogsManager.getAuditBarGraphData(request);
   }
 
   @GET
-  @Path("/users")
-  @Produces({"application/json"})
-  @ApiOperation(GET_TOP_AUDIT_USERS_OD)
-  public BarGraphDataListResponse getTopAuditUsers(@BeanParam FieldAuditBarGraphRequest request) {
-    return auditLogsManager.topTenUsers(conversionService.convert(request, FieldAuditBarGraphSearchCriteria.class));
-  }
-
-  @GET
-  @Path("/resources")
+  @Path("/resources/{top}")
   @Produces({"application/json"})
   @ApiOperation(GET_TOP_AUDIT_RESOURCES_OD)
-  public BarGraphDataListResponse getTopAuditResources(@BeanParam FieldAuditLogRequest request) {
-    return auditLogsManager.topTenResources(conversionService.convert(request, FieldAuditLogSearchCriteria.class));
-  }
-
-  @GET
-  @Path("/live/count")
-  @Produces({"application/json"})
-  @ApiOperation(GET_LIVE_LOGS_COUNT_OD)
-  public NameValueDataListResponse getLiveLogsCount() {
-    return auditLogsManager.getLiveLogCounts();
-  }
-
-  @GET
-  @Path("/request/user/bargraph")
-  @Produces({"application/json"})
-  @ApiOperation(GET_REQUEST_USER_LINE_GRAPH_OD)
-  public BarGraphDataListResponse getRequestUserBarGraph(@BeanParam FieldAuditBarGraphRequest request) {
-    return auditLogsManager.getRequestUserLineGraph(conversionService.convert(request, FieldAuditBarGraphSearchCriteria.class));
-  }
-
-  @GET
-  @Path("/anygraph")
-  @Produces({"application/json"})
-  @ApiOperation(GET_ANY_GRAPH_DATA_OD)
-  public BarGraphDataListResponse getAnyGraphData(@BeanParam AnyGraphRequest request) {
-    return auditLogsManager.getAnyGraphData(conversionService.convert(request, AnyGraphSearchCriteria.class));
+  public BarGraphDataListResponse getResources(@BeanParam FieldAuditLogRequest request) {
+    return auditLogsManager.topResources(request);
   }
 
   @GET
-  @Path("/users/export")
+  @Path("/export")
   @Produces({"application/json"})
   @ApiOperation(EXPORT_USER_TALBE_TO_TEXT_FILE_OD)
-  public Response exportUserTableToTextFile(@BeanParam UserExportRequest request) {
-    return auditLogsManager.exportUserTableToTextFile(conversionService.convert(request, UserExportSearchCriteria.class));
+  public Response exportUserTableToTextFile(@BeanParam UserExportRequest request) throws TemplateException {
+    return auditLogsManager.export(request);
   }
 
   @GET
   @Path("/serviceload")
   @Produces({"application/json"})
   @ApiOperation(GET_SERVICE_LOAD_OD)
-  public BarGraphDataListResponse getServiceLoad(@BeanParam BaseAuditLogRequest request) {
-    return auditLogsManager.getServiceLoad(conversionService.convert(request, CommonSearchCriteria.class));
+  public BarGraphDataListResponse getServiceLoad(@BeanParam AuditServiceLoadRequest request) {
+    return auditLogsManager.getServiceLoad(request);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java
index 94bf059..df83d44 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java
@@ -19,6 +19,7 @@
 package org.apache.ambari.logsearch.rest;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 
@@ -26,13 +27,12 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.ambari.logsearch.manager.PublicManager;
 import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
 
 import static org.apache.ambari.logsearch.doc.DocConstants.PublicOperationDescriptions.OBTAIN_GENERAL_CONFIG_OD;
 
 @Api(value = "public", description = "Public operations")
 @Path("public")
-@Component
+@Named
 @Scope("request")
 public class PublicResource {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
index 5a17147..d6ceca5 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
@@ -19,21 +19,23 @@
 package org.apache.ambari.logsearch.rest;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.ws.rs.BeanParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
 import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
-import org.apache.ambari.logsearch.model.request.impl.ServiceExtremeDatesRequest;
 import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogAggregatedInfoRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentHostRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentLevelRequest;
 import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogHostComponentRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogLevelCountRequest;
 import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest;
 import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
@@ -43,23 +45,15 @@ import org.apache.ambari.logsearch.model.response.GroupListResponse;
 import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
 import org.apache.ambari.logsearch.model.response.NodeListResponse;
 import org.apache.ambari.logsearch.model.response.ServiceLogResponse;
-import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
 import org.apache.ambari.logsearch.manager.ServiceLogsManager;
-import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceExtremeDatesCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria;
 import org.springframework.context.annotation.Scope;
 import org.springframework.core.convert.ConversionService;
-import org.springframework.stereotype.Component;
 
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceOperationDescriptions.*;
 
 @Api(value = "service/logs", description = "Service log operations")
 @Path("service/logs")
-@Component
+@Named
 @Scope("request")
 public class ServiceLogsResource {
 
@@ -73,7 +67,7 @@ public class ServiceLogsResource {
   @Produces({"application/json"})
   @ApiOperation(SEARCH_LOGS_OD)
   public ServiceLogResponse searchSolrData(@BeanParam ServiceLogRequest request) {
-    return serviceLogsManager.searchLogs(conversionService.convert(request, ServiceLogSearchCriteria.class));
+    return serviceLogsManager.searchLogs(request);
   }
 
   @GET
@@ -96,16 +90,8 @@ public class ServiceLogsResource {
   @Path("/aggregated")
   @Produces({"application/json"})
   @ApiOperation(GET_AGGREGATED_INFO_OD)
-  public GraphDataListResponse getAggregatedInfo(@BeanParam BaseServiceLogRequest request) {
-    return serviceLogsManager.getAggregatedInfo(conversionService.convert(request, CommonServiceLogSearchCriteria.class));
-  }
-
-  @GET
-  @Path("/levels/count")
-  @Produces({"application/json"})
-  @ApiOperation(GET_LOG_LEVELS_COUNT_OD)
-  public CountDataListResponse getLogLevelsCount() {
-    return serviceLogsManager.getLogLevelCount();
+  public GraphDataListResponse getAggregatedInfo(@BeanParam ServiceLogAggregatedInfoRequest request) {
+    return serviceLogsManager.getAggregatedInfo(request);
   }
 
   @GET
@@ -128,18 +114,16 @@ public class ServiceLogsResource {
   @Path("/tree")
   @Produces({"application/json"})
   @ApiOperation(GET_TREE_EXTENSION_OD)
-  public NodeListResponse getTreeExtension(@QueryParam("hostName") @ApiParam String hostName, @BeanParam ServiceLogRequest request) {
-    ServiceLogSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogSearchCriteria.class);
-    searchCriteria.addParam("hostName", hostName); // TODO: use host_name instead - needs UI change
-    return serviceLogsManager.getTreeExtension(searchCriteria);
+  public NodeListResponse getTreeExtension(@BeanParam ServiceLogHostComponentRequest request) {
+    return serviceLogsManager.getTreeExtension(request);
   }
 
   @GET
-  @Path("/levels/counts/namevalues")
+  @Path("/levels/counts")
   @Produces({"application/json"})
   @ApiOperation(GET_LOG_LEVELS_COUNT_OD)
-  public NameValueDataListResponse getLogsLevelCount(@BeanParam ServiceLogRequest request) {
-    return serviceLogsManager.getLogsLevelCount(conversionService.convert(request, ServiceLogSearchCriteria.class));
+  public NameValueDataListResponse getLogsLevelCount(@BeanParam ServiceLogLevelCountRequest request) {
+    return serviceLogsManager.getLogsLevelCount(request);
   }
 
   @GET
@@ -147,15 +131,7 @@ public class ServiceLogsResource {
   @Produces({"application/json"})
   @ApiOperation(GET_HISTOGRAM_DATA_OD)
   public BarGraphDataListResponse getHistogramData(@BeanParam ServiceGraphRequest request) {
-    return serviceLogsManager.getHistogramData(conversionService.convert(request, ServiceGraphSearchCriteria.class));
-  }
-
-  @GET
-  @Path("/request/cancel")
-  @Produces({"application/json"})
-  @ApiOperation(CANCEL_FIND_REQUEST_OD)
-  public String cancelFindRequest(@QueryParam("token") @ApiParam String token) {
-    return serviceLogsManager.cancelFindRequestByDate(token);
+    return serviceLogsManager.getHistogramData(request);
   }
 
   @GET
@@ -163,36 +139,24 @@ public class ServiceLogsResource {
   @Produces({"application/json"})
   @ApiOperation(EXPORT_TO_TEXT_FILE_OD)
   public Response exportToTextFile(@BeanParam ServiceLogExportRequest request) {
-    return serviceLogsManager.exportToTextFile(conversionService.convert(request, ServiceLogExportSearchCriteria.class));
-
+    return serviceLogsManager.export(request);
   }
 
   @GET
   @Path("/hosts/components")
   @Produces({"application/json"})
   @ApiOperation(GET_HOST_LIST_BY_COMPONENT_OD)
-  public NodeListResponse getHostListByComponent(@BeanParam ServiceLogRequest request, @QueryParam("componentName") @ApiParam String componentName) {
-    ServiceLogSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogSearchCriteria.class);
-    searchCriteria.addParam("componentName", componentName); // TODO: use component_name instead - needs UI change
-    return serviceLogsManager.getHostListByComponent(searchCriteria);
+  public NodeListResponse getHostListByComponent(@BeanParam ServiceLogComponentHostRequest request) {
+    return serviceLogsManager.getHostListByComponent(request);
   }
 
   @GET
   @Path("/components/levels/counts")
   @Produces({"application/json"})
   @ApiOperation(GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD)
-  public NodeListResponse getComponentListWithLevelCounts(@BeanParam ServiceLogRequest request) {
-    return serviceLogsManager.getComponentListWithLevelCounts(conversionService.convert(request, ServiceLogSearchCriteria.class));
+  public NodeListResponse getComponentListWithLevelCounts(@BeanParam ServiceLogComponentLevelRequest request) {
+    return serviceLogsManager.getComponentListWithLevelCounts(request);
   }
-
-  @GET
-  @Path("/solr/boundarydates")
-  @Produces({"application/json"})
-  @ApiOperation(GET_EXTREME_DATES_FOR_BUNDLE_ID_OD)
-  public NameValueDataListResponse getExtremeDatesForBundelId(@BeanParam ServiceExtremeDatesRequest request) {
-    return serviceLogsManager.getExtremeDatesForBundelId(conversionService.convert(request, ServiceExtremeDatesCriteria.class));
-  }
-
   @GET
   @Path("/schema/fields")
   @Produces({"application/json"})
@@ -202,11 +166,11 @@ public class ServiceLogsResource {
   }
 
   @GET
-  @Path("/anygraph")
+  @Path("/count/anygraph")
   @Produces({"application/json"})
-  @ApiOperation(GET_ANY_GRAPH_DATA_OD)
-  public BarGraphDataListResponse getAnyGraphData(@BeanParam ServiceAnyGraphRequest request) {
-    return serviceLogsManager.getAnyGraphData(conversionService.convert(request, ServiceAnyGraphSearchCriteria.class));
+  @ApiOperation(GET_ANY_GRAPH_COUNT_DATA_OD)
+  public BarGraphDataListResponse getAnyGraphCountData(@BeanParam ServiceAnyGraphRequest request) {
+    return serviceLogsManager.getAnyGraphCountData(request);
   }
 
   @GET
@@ -214,7 +178,7 @@ public class ServiceLogsResource {
   @Produces({"application/json"})
   @ApiOperation(GET_AFTER_BEFORE_LOGS_OD)
   public ServiceLogResponse getAfterBeforeLogs(@BeanParam ServiceLogTruncatedRequest request) {
-    return serviceLogsManager.getAfterBeforeLogs(conversionService.convert(request, ServiceLogTruncatedSearchCriteria.class));
+    return serviceLogsManager.getAfterBeforeLogs(request);
   }
 
   @GET

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
index fd36978..1cfc8f8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
@@ -20,6 +20,7 @@
 package org.apache.ambari.logsearch.rest;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.ws.rs.BeanParam;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -37,13 +38,12 @@ import org.apache.ambari.logsearch.query.model.UserConfigSearchCriteria;
 import org.apache.ambari.logsearch.view.VUserConfig;
 import org.springframework.context.annotation.Scope;
 import org.springframework.core.convert.ConversionService;
-import org.springframework.stereotype.Component;
 
 import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigOperationDescriptions.*;
 
 @Api(value = "userconfig", description = "User config operations")
 @Path("userconfig")
-@Component
+@Named
 @Scope("request")
 public class UserConfigResource {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java
new file mode 100644
index 0000000..1ea30bc
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.solr;
+
+public class SolrConstants {
+
+  private SolrConstants() {
+  }
+
+
+  public class CommonLogConstants {
+    private CommonLogConstants() {
+    }
+    public static final String ID = "id";
+    public static final String SEQUENCE_ID = "seq_num";
+  }
+
+  public class ServiceLogConstants {
+
+    private ServiceLogConstants() {
+    }
+
+    public static final String BUNDLE_ID = "bundle_id";
+    public static final String LOGTIME = "logtime";
+    public static final String COMPONENT = "type";
+    public static final String LOG_MESSAGE = "log_message";
+    public static final String KEY_LOG_MESSAGE = "key_log_message";
+    public static final String HOST = "host";
+    public static final String LEVEL = "level";
+    public static final String THREAD_NAME = "thread_name";
+    public static final String LOGGER_NAME = "logger_name";
+    public static final String FILE = "file";
+    public static final String LINE_NUMBER = "line_number";
+    public static final String PATH = "path";
+  }
+
+  public class AuditLogConstants {
+    private AuditLogConstants() {
+    }
+
+    public static final String AUDIT_COMPONENT = "repo";
+    public static final String AUDIT_EVTTIME = "evtTime";
+    public static final String AUDIT_REQUEST_USER = "reqUser";
+    public static final String AUDIT_RESOURCE = "resource";
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
deleted file mode 100644
index 637a4d7..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.response.BarGraphData;
-import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
-import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.view.VHost;
-import org.apache.ambari.logsearch.view.VSummary;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-
-public class BizUtil {
-  private static final Logger logger = Logger.getLogger(BizUtil.class);
-
-  private BizUtil() {
-    throw new UnsupportedOperationException();
-  }
-  
-  public static String convertObjectToNormalText(SolrDocumentList docList) {
-    String textToSave = "";
-    HashMap<String, String> blankFieldsMap = new HashMap<String, String>();
-    if (docList == null){
-      return "no data";
-    }
-    if (docList.isEmpty()) {
-      return "no data";
-    }
-    SolrDocument docForBlankCaculation = docList.get(0);
-    if(docForBlankCaculation == null){
-      return "no data";
-    }
-    Collection<String> fieldsForBlankCaculation = docForBlankCaculation.getFieldNames();
-
-    int maxLengthOfField = 0;
-    if (fieldsForBlankCaculation == null) {
-      return "no data";
-    }
-    for (String field : fieldsForBlankCaculation) {
-      if (!StringUtils.isBlank(field) && field.length() > maxLengthOfField) {
-        maxLengthOfField = field.length();
-      }
-    }
-
-    for (String field : fieldsForBlankCaculation) {
-      if (!StringUtils.isBlank(field)) {
-        blankFieldsMap.put(field, StringUtils.rightPad(field, maxLengthOfField - field.length()));
-      }
-    }
-
-    for (SolrDocument doc : docList) {
-      if (doc != null) {
-        StringBuffer textTowrite = new StringBuffer();
-
-        if (doc.getFieldValue(LogSearchConstants.LOGTIME) != null) {
-          textTowrite.append(doc.getFieldValue(LogSearchConstants.LOGTIME).toString() + " ");
-        }
-        if (doc.getFieldValue(LogSearchConstants.SOLR_LEVEL) != null) {
-          textTowrite.append(doc.getFieldValue(LogSearchConstants.SOLR_LEVEL).toString()).append(" ");
-        }
-        if (doc.getFieldValue(LogSearchConstants.SOLR_THREAD_NAME) != null) {
-          textTowrite.append(doc.getFieldValue(LogSearchConstants.SOLR_THREAD_NAME).toString().trim()).append(" ");
-        }
-        if (doc.getFieldValue(LogSearchConstants.SOLR_LOGGER_NAME) != null) {
-          textTowrite.append(doc.getFieldValue(LogSearchConstants.SOLR_LOGGER_NAME).toString().trim()).append(" ");
-        }
-        if (doc.getFieldValue(LogSearchConstants.SOLR_FILE) != null && doc.getFieldValue(LogSearchConstants.SOLR_LINE_NUMBER) != null) {
-          textTowrite
-              .append(doc.getFieldValue(LogSearchConstants.SOLR_FILE).toString())
-              .append(":")
-              .append(doc.getFieldValue(LogSearchConstants.SOLR_LINE_NUMBER).toString())
-              .append(" ");
-        }
-        if (doc.getFieldValue(LogSearchConstants.SOLR_LOG_MESSAGE) != null) {
-          textTowrite.append("- ")
-              .append(doc.getFieldValue(LogSearchConstants.SOLR_LOG_MESSAGE).toString());
-        }
-        textTowrite.append("\n");
-        textToSave += textTowrite.toString();
-      }
-    }
-    return textToSave;
-  }
-
-  public static VSummary buildSummaryForLogFile(SolrDocumentList docList) {
-    VSummary vsummary = new VSummary();
-    if (CollectionUtils.isEmpty(docList)) {
-      return vsummary;
-    }
-    int numLogs = 0;
-    List<VHost> vHosts = new ArrayList<VHost>();
-    vsummary.setHosts(vHosts);
-    String levels = "";
-    for (SolrDocument doc : docList) {
-      if (doc != null) {
-        // adding Host and Component appropriately
-        String hostname = (String) doc.getFieldValue("host");
-        String comp = (String) doc.getFieldValue("type");
-        String level = (String) doc.getFieldValue("level");
-        if (StringUtils.isBlank(level)) {
-          level = "";
-        }
-        boolean newHost = true;
-        for (VHost host : vHosts) {
-          if (host != null && host.getName().equals(hostname)) {
-            newHost = false;
-            if (StringUtils.isBlank(comp)) {
-              Set<String> compList = host.getComponents();
-              if (compList != null) {
-                compList.add(comp);
-              }
-            }
-            break;
-          }
-        }
-        if (newHost) {
-          VHost vHost = new VHost();
-          if (!StringUtils.isBlank(hostname)) {
-            vHost.setName(hostname);
-          }
-          Set<String> component = new LinkedHashSet<String>();
-          if (StringUtils.isBlank(comp)) {
-            component.add(comp);
-          }
-          vHost.setComponents(component);
-          vHosts.add(vHost);
-        }
-        // getting levels
-        if (!levels.contains(level)) {
-          levels = levels + ", " + level;
-        }
-        numLogs += 1;
-      }
-  }
-    levels = levels.replaceFirst(", ", "");
-    vsummary.setLevels(levels);
-    vsummary.setNumberLogs("" + numLogs);
-    return vsummary;
-  }
-
-  @SuppressWarnings({"unchecked", "rawtypes"})
-  public static BarGraphDataListResponse buildSummaryForTopCounts(SimpleOrderedMap<Object> jsonFacetResponse, String innerJsonKey, String outerJsonKey) {
-
-    BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
-
-    Collection<BarGraphData> dataList = new ArrayList<>();
-    if (jsonFacetResponse == null) {
-      logger.info("Solr document list in null");
-      return barGraphDataListResponse;
-    }
-    List<Object> userList = jsonFacetResponse.getAll(outerJsonKey);
-    if (userList.isEmpty()) {
-      return barGraphDataListResponse;
-    }
-    SimpleOrderedMap<Map<String, Object>> userMap = (SimpleOrderedMap<Map<String, Object>>) userList.get(0);
-    if (userMap == null) {
-      logger.info("No top user details found");
-      return barGraphDataListResponse;
-    }
-    List<SimpleOrderedMap> userUsageList = (List<SimpleOrderedMap>) userMap.get("buckets");
-    if(userUsageList == null){
-      return barGraphDataListResponse;
-    }
-    for (SimpleOrderedMap usageMap : userUsageList) {
-      if (usageMap != null) {
-        BarGraphData barGraphData = new BarGraphData();
-        String userName = (String) usageMap.get("val");
-        if (!StringUtils.isBlank(userName)) {
-          barGraphData.setName(userName);
-        }
-        SimpleOrderedMap repoMap = (SimpleOrderedMap) usageMap.get(innerJsonKey);
-        List<NameValueData> componetCountList = new ArrayList<NameValueData>();
-        if (repoMap != null) {
-          List<SimpleOrderedMap> repoUsageList = (List<SimpleOrderedMap>) repoMap.get("buckets");
-          for (SimpleOrderedMap repoUsageMap : repoUsageList) {
-            NameValueData componetCount = new NameValueData();
-            if (repoUsageMap.get("val") != null) {
-              componetCount.setName(repoUsageMap.get("val").toString());
-            }
-            String eventCount = "";
-            if (repoUsageMap.get("eventCount") != null) {
-              eventCount = repoUsageMap.get("eventCount").toString();
-            }
-            eventCount = eventCount.replace(".0", "");
-            eventCount = eventCount.replace(".00", "");
-
-            componetCount.setValue(eventCount);
-            componetCountList.add(componetCount);
-          }
-          barGraphData.setDataCount(componetCountList);
-          dataList.add(barGraphData);
-        }
-      }}
-    barGraphDataListResponse.setGraphData(dataList);
-    logger.info("getting graph data");
-
-    return barGraphDataListResponse;
-  }
-  
-  public static HashMap<String, String> sortHashMapByValues(HashMap<String, String> passedMap) {
-    if (passedMap == null ) {
-      return null;
-    }
-    HashMap<String, String> sortedMap = new LinkedHashMap<String, String>();
-    List<String> mapValues = new ArrayList<String>(passedMap.values());
-    HashMap<String, String> invertedKeyValue = new HashMap<String, String>();
-    Collections.sort(mapValues, new Comparator<String>() {
-      @Override
-      public int compare(String s1, String s2) {
-        return s1.compareToIgnoreCase(s2);
-      }
-    });
-    Iterator<Entry<String, String>> it = passedMap.entrySet().iterator();
-    while (it.hasNext()) {
-      @SuppressWarnings("rawtypes")
-      Map.Entry pair = (Map.Entry) it.next();
-      invertedKeyValue.put("" + pair.getValue(), "" + pair.getKey());
-    }
-
-    for (String valueOfKey : mapValues) {
-      sortedMap.put(invertedKeyValue.get(valueOfKey), valueOfKey);
-    }
-
-    return sortedMap;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java
index 0de0dbc..9b4f553 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java
@@ -114,6 +114,15 @@ public class DateUtil {
 
   }
 
+  public static Date convertStringToSolrDate(String dateStr) {
+    try {
+      SimpleDateFormat formatter = new SimpleDateFormat(LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z);
+      return formatter.parse(dateStr);
+    } catch (Exception e){
+      throw new RuntimeException("Cannot parse date from request", e.getCause());
+    }
+  }
+
   public static boolean isDateValid(String value) {
     if (StringUtils.isBlank(value)) {
       return false;


[6/7] ambari git commit: AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java
deleted file mode 100644
index c57e0e9..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.graph;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.ambari.logsearch.manager.ManagerBase;
-import org.apache.ambari.logsearch.model.response.BarGraphData;
-import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.util.DateUtil;
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-
-class GraphDataGeneratorBase {
-
-  private static final String BUCKETS = "buckets";
-  
-  private static enum DataType {
-    LONG("long"),
-    DOUBLE("double"),
-    FLOAT("long"),
-    INT("long");
-    
-    private String type;
-    
-    DataType(String type) {
-      this.type = type;
-    }
-    
-    String getType() {
-      return type;
-    }
-  }
-
-  protected static enum GraphType {
-    UNKNOWN,
-    NORMAL_GRAPH,
-    RANGE_NON_STACK_GRAPH,
-    NON_RANGE_STACK_GRAPH,
-    RANGE_STACK_GRAPH;
-  }
-
-  @SuppressWarnings("unchecked")
-  protected void extractRangeStackValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String outerField,
-      String innerField, List<BarGraphData> histogramData) {
-    if (jsonFacetResponse != null) {
-      NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
-      if (stack != null) {
-        ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get(BUCKETS);
-        if (stackBuckets != null) {
-          for (Object stackBucket : stackBuckets) {
-            BarGraphData vBarGraphData = new BarGraphData();
-            SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) stackBucket;
-            if (level != null) {
-              String name = level.getVal(0) != null ? level.getVal(0).toString().toUpperCase() : "";
-              vBarGraphData.setName(name);
-              Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
-              NamedList<Object> innerFiledValue = (NamedList<Object>) level.get(innerField);
-              if (innerFiledValue != null) {
-                ArrayList<Object> levelBuckets = (ArrayList<Object>) innerFiledValue.get(BUCKETS);
-                if (levelBuckets != null) {
-                  for (Object levelBucket : levelBuckets) {
-                    SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) levelBucket;
-                    if (countValue != null) {
-                      String innerName = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
-                      String innerValue = countValue.getVal(1) != null ? countValue.getVal(1).toString() : "";
-                      NameValueData vNameValue = new NameValueData();
-                      vNameValue.setName(innerName);
-                      vNameValue.setValue(innerValue);
-                      vNameValues.add(vNameValue);
-                    }
-                  }
-                }
-              }
-              vBarGraphData.setDataCount(vNameValues);
-            }
-            histogramData.add(vBarGraphData);
-          }
-        }
-      }
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  protected boolean extractNonRangeStackValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String level,
-      Collection<BarGraphData> vGraphDatas, String typeXAxis) {
-    boolean zeroFlag = true;
-    if (jsonFacetResponse == null || jsonFacetResponse.get(level) == null
-        || jsonFacetResponse.get(level).toString().equals("{count=0}")) {
-      return false;
-    }
-    NamedList<Object> levelList = (NamedList<Object>) jsonFacetResponse.get(level);
-    if (levelList != null) {
-      ArrayList<Object> bucketList = (ArrayList<Object>) levelList.get(BUCKETS);
-      if (bucketList != null) {
-        for (int index = 0; index < bucketList.size(); index++) {
-          SimpleOrderedMap<Object> valueCount = (SimpleOrderedMap<Object>) bucketList.get(index);
-          if (valueCount != null && valueCount.size() > 2) {
-            BarGraphData vGraphData = new BarGraphData();
-            Collection<NameValueData> levelCounts = new ArrayList<NameValueData>();
-            String name = valueCount.getVal(0) != null ? valueCount.getVal(0).toString().trim() : "";
-            if (isTypeNumber(typeXAxis)) {
-              NameValueData nameValue = new NameValueData();
-              Double sumValue = (Double) valueCount.getVal(2);
-              String value = "0";// default is zero
-              if (sumValue != null) {
-                value = "" + sumValue.longValue();
-              }
-              nameValue.setName(name);
-              nameValue.setValue(value);
-              levelCounts.add(nameValue);
-            } else {
-              SimpleOrderedMap<Object> valueCountMap = (SimpleOrderedMap<Object>) valueCount.getVal(2);
-              if (valueCountMap != null) {
-                ArrayList<Object> buckets = (ArrayList<Object>) valueCountMap.get(BUCKETS);
-                if (buckets != null) {
-                  for (int innerIndex = 0; innerIndex < buckets.size(); innerIndex++) {
-                    SimpleOrderedMap<Object> innerValueCount = (SimpleOrderedMap<Object>) buckets.get(innerIndex);
-                    if (innerValueCount != null) {
-                      String innerName = innerValueCount.getVal(0) != null ? innerValueCount.getVal(0).toString().trim() : "";
-                      String innerValue = innerValueCount.getVal(1) != null ? innerValueCount.getVal(1).toString().trim() : "";
-                      NameValueData nameValue = new NameValueData();
-                      nameValue.setValue(innerValue);
-                      nameValue.setName(innerName);
-                      levelCounts.add(nameValue);
-                    }
-                  }
-                }
-              }
-            }
-            vGraphData.setName(name);
-            vGraphData.setDataCount(levelCounts);
-            vGraphDatas.add(vGraphData);
-          }
-        }
-      }
-    }
-    return zeroFlag;
-  }
-
-  protected boolean isTypeNumber(String typeXAxis) {
-    if (StringUtils.isBlank(typeXAxis)) {
-      return false;
-    } else {
-      return typeXAxis.contains(DataType.LONG.getType()) || typeXAxis.contains(DataType.INT.getType())
-          || typeXAxis.contains(DataType.FLOAT.getType()) || typeXAxis.contains(DataType.DOUBLE.getType());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
index 52482c2..56ba2d7 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
@@ -20,398 +20,151 @@
 package org.apache.ambari.logsearch.manager;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.text.ParseException;
+import java.io.StringWriter;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.ManageStartEndTime;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
 import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
 import org.apache.ambari.logsearch.dao.AuditSolrDao;
 import org.apache.ambari.logsearch.graph.GraphDataGenerator;
+import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
 import org.apache.ambari.logsearch.model.response.AuditLogResponse;
 import org.apache.ambari.logsearch.model.response.BarGraphData;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
 import org.apache.ambari.logsearch.model.response.GroupListResponse;
 import org.apache.ambari.logsearch.model.response.LogData;
-import org.apache.ambari.logsearch.model.response.LogSearchResponse;
 import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
-import org.apache.ambari.logsearch.query.model.AnyGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
+import org.apache.ambari.logsearch.model.response.TemplateData;
+import org.apache.ambari.logsearch.solr.SolrConstants;
 import org.apache.ambari.logsearch.solr.model.SolrAuditLogData;
 import org.apache.ambari.logsearch.solr.model.SolrComponentTypeLogData;
-import org.apache.ambari.logsearch.util.BizUtil;
-import org.apache.ambari.logsearch.util.DateUtil;
+import org.apache.ambari.logsearch.util.DownloadUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
 import org.apache.ambari.logsearch.view.VResponse;
-import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField;
 import org.apache.solr.client.solrj.response.FacetField.Count;
 import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.RangeFacet;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.stereotype.Component;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleQuery;
 
-@Component
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
 public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResponse> {
   private static final Logger logger = Logger.getLogger(AuditLogsManager.class);
 
+  private static final String AUDIT_LOG_TEMPLATE = "audit_log_txt.ftl";
+
   @Inject
   private AuditSolrDao auditSolrDao;
   @Inject
   private GraphDataGenerator graphDataGenerator;
   @Inject
-  private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
+  private ConversionService conversionService;
+  @Inject
+  private Configuration freemarkerConfiguration;
 
-  public AuditLogResponse getLogs(AuditLogSearchCriteria searchCriteria) {
-    Boolean isLastPage = searchCriteria.isLastPage();
-    if (isLastPage) {
-      SolrQuery lastPageQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-      LogSearchResponse logResponse = getLastPage(searchCriteria, LogSearchConstants.AUDIT_EVTTIME, auditSolrDao, lastPageQuery);
-      if (logResponse == null) {
-        logResponse = new AuditLogResponse();
-      }
-      return (AuditLogResponse) logResponse;
-    }
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    return getLogAsPaginationProvided(solrQuery, auditSolrDao);
+  public AuditLogResponse getLogs(AuditLogRequest auditLogRequest) {
+    return getLogAsPaginationProvided(conversionService.convert(auditLogRequest, SimpleQuery.class), auditSolrDao, "/audit/logs");
   }
 
-  private List<LogData> getComponents(CommonSearchCriteria searchCriteria) {
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+  private List<LogData> getComponents(AuditComponentRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
     List<LogData> docList = new ArrayList<>();
-    try {
-      SolrUtil.setFacetField(solrQuery, LogSearchConstants.AUDIT_COMPONENT);
-      SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-      List<FacetField> facetFields = null;
-      List<Count> componentsCount = new ArrayList<Count>();
-      FacetField facetField = null;
+    QueryResponse queryResponse = auditSolrDao.process(facetQuery);
+    List<Count> componentsCount = graphDataGenerator.generateCount(queryResponse);
 
-      QueryResponse queryResponse = auditSolrDao.process(solrQuery);
-      if (queryResponse == null) {
-        return docList;
-      }
-
-      facetFields = queryResponse.getFacetFields();
-      if (facetFields == null) {
-        return docList;
-      }
-      if (!facetFields.isEmpty()) {
-        facetField = facetFields.get(0);
-      }
-      if (facetField != null) {
-        componentsCount = facetField.getValues();
-      }
-
-      for (Count component : componentsCount) {
-        SolrComponentTypeLogData logData = new SolrComponentTypeLogData();
-        logData.setType(component.getName());
-        docList.add(logData);
-      }
-      return docList;
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+    for (Count component : componentsCount) {
+      SolrComponentTypeLogData logData = new SolrComponentTypeLogData();
+      logData.setType(component.getName());
+      docList.add(logData);
     }
+    return docList;
   }
 
-  public GroupListResponse getAuditComponents(CommonSearchCriteria searchCriteria) {
+  public GroupListResponse getAuditComponents(AuditComponentRequest request) {
     GroupListResponse componentResponse = new GroupListResponse();
-    List<LogData> docList = getComponents(searchCriteria);
+    List<LogData> docList = getComponents(request);
     componentResponse.setGroupList(docList);
     return componentResponse;
   }
 
-  @SuppressWarnings("unchecked")
-  public BarGraphDataListResponse getAuditBarGraphData(AuditBarGraphSearchCriteria searchCriteria) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
-    String from = getFrom(searchCriteria.getStartTime());
-    String to = getTo(searchCriteria.getEndTime());
-    String unit = getUnit(searchCriteria.getUnit());
-
-    List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
-    String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_COMPONENT,
-      LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
-
-    return getGraphResponse(dataList, solrQuery, histogramData, jsonHistogramQuery);
-  }
-
-  @SuppressWarnings({"unchecked", "rawtypes"})
-  public NameValueDataListResponse getLiveLogCounts() {
-    NameValueDataListResponse nameValueList = new NameValueDataListResponse();
-    SolrQuery solrQuery = new SolrQuery();
-    solrQuery.setParam("event", "/audit/logs/live/count");
-    try {
-      Date[] timeRange = ManageStartEndTime.getStartEndTime();
-      String startDate = DateUtil.convertGivenDateFormatToSolrDateFormat(timeRange[0]);
-      String endDate = DateUtil.convertGivenDateFormatToSolrDateFormat(timeRange[1]);
-
-      SolrUtil.setMainQuery(solrQuery, null);
-      SolrUtil.setFacetRange(solrQuery, LogSearchConstants.AUDIT_EVTTIME, startDate, endDate, "+2MINUTE");
-      List<RangeFacet.Count> listCount;
-
-      QueryResponse response = auditSolrDao.process(solrQuery);
-
-      List<RangeFacet> rangeFacet = response.getFacetRanges();
-      if (rangeFacet == null) {
-        return nameValueList;
-      }
-      RangeFacet range = rangeFacet.get(0);
-
-      if (range == null) {
-        return nameValueList;
-      }
-
-      listCount = range.getCounts();
-
-      List<NameValueData> nameValues = new ArrayList<>();
-      int count = 0;
-      for (RangeFacet.Count cnt : listCount) {
-        NameValueData nameValue = new NameValueData();
-        nameValue.setName("" + count);
-        nameValue.setValue("" + cnt.getCount());
-        nameValues.add(nameValue);
-        count++;
-      }
-      nameValueList.setvNameValues(nameValues);
-      return nameValueList;
-
-    } catch (SolrException | SolrServerException | ParseException
-      | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-  }
-
-  public BarGraphDataListResponse topTenUsers(FieldAuditBarGraphSearchCriteria searchCriteria) {
-
-    String jsonUserQuery =
-      "{Users:{type:terms, field:reqUser, facet:{ Repo:{ type:terms, field:repo, facet:{eventCount:\"sum(event_count)\"}}}}}";
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
-    SolrUtil.setRowCount(solrQuery, 0);
-    try {
-      BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
-      QueryResponse queryResponse = auditSolrDao.process(solrQuery);
-      if (queryResponse == null) {
-        return barGraphDataListResponse;
-      }
-
-      NamedList<Object> namedList = queryResponse.getResponse();
-
-      if (namedList == null) {
-        return barGraphDataListResponse;
-      }
-
-      @SuppressWarnings("unchecked")
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
-      if (jsonFacetResponse == null) {
-        return barGraphDataListResponse;
-      }
-      if (jsonFacetResponse.toString().equals("{count=0}")) {
-        return barGraphDataListResponse;
-      }
-      barGraphDataListResponse = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
-      return barGraphDataListResponse;
-
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error("Error during solrQuery=" + e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-  }
-
-  public BarGraphDataListResponse topTenResources(FieldAuditLogSearchCriteria searchCriteria) {
-
-    String jsonUserQuery =
-      "{Users:{type:terms,field:resource,facet:{Repo:{type:terms,field:repo,facet:{eventCount:\"sum(event_count)\"}}}}}";
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
-    SolrUtil.setRowCount(solrQuery, 0);
-    try {
-      BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
-      QueryResponse queryResponse = auditSolrDao.process(solrQuery);
-      if (queryResponse == null) {
-        return barGraphDataListResponse;
-      }
-
-      NamedList<Object> namedList = queryResponse.getResponse();
-      if (namedList == null) {
-        return barGraphDataListResponse;
-      }
-
-      @SuppressWarnings("unchecked")
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
-
-      barGraphDataListResponse = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
-      return barGraphDataListResponse;
-
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
+  public BarGraphDataListResponse getAuditBarGraphData(AuditBarGraphRequest request) {
+    SolrQuery solrQuery = conversionService.convert(request, SolrQuery.class);
+    QueryResponse response = auditSolrDao.process(solrQuery);
+    return graphDataGenerator.generateBarGraphDataResponseWithRanges(response, SolrConstants.AuditLogConstants.AUDIT_COMPONENT, true);
   }
 
-  @SuppressWarnings("unchecked")
-  public BarGraphDataListResponse getRequestUserLineGraph(FieldAuditBarGraphSearchCriteria searchCriteria) {
-
-    String from = getFrom(searchCriteria.getStartTime());
-    String to = getTo(searchCriteria.getEndTime());
-    String unit = getUnit(searchCriteria.getUnit());
-
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
-
-    SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-
-    String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_REQUEST_USER,
-      LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
-
-    return getGraphResponse(dataList, solrQuery, histogramData, jsonHistogramQuery);
+  public BarGraphDataListResponse topResources(FieldAuditLogRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    QueryResponse queryResponse = auditSolrDao.process(facetQuery);
+    return graphDataGenerator.generateSecondLevelBarGraphDataResponse(queryResponse, 0);
   }
 
   public String getAuditLogsSchemaFieldsName() {
-    return convertObjToString(auditSolrDao.schemaFieldNameMap);
+    return convertObjToString(auditSolrDao.getSolrSchemaFieldDao().getSchemaFieldNameMap());
   }
 
-  public BarGraphDataListResponse getAnyGraphData(AnyGraphSearchCriteria searchCriteria) {
-    searchCriteria.addParam("fieldTime", LogSearchConstants.AUDIT_EVTTIME);
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    BarGraphDataListResponse result = graphDataGenerator.getAnyGraphData(searchCriteria, auditSolrDao, solrQuery);
-    if (result == null) {
-      result = new BarGraphDataListResponse();
-    }
-    return result;
-
+  public BarGraphDataListResponse getServiceLoad(AuditServiceLoadRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    QueryResponse response = auditSolrDao.process(facetQuery);
+    return graphDataGenerator.generateBarGraphFromFieldFacet(response, AUDIT_COMPONENT);
   }
 
-  @SuppressWarnings({"unchecked"})
-  public Response exportUserTableToTextFile(UserExportSearchCriteria searchCriteria) {
-    String jsonUserQuery =
-      "{ Users: { type: terms, field: reqUser, facet:  {Repo: {  type: terms, field: repo, facet: {  eventCount: \"sum(event_count)\"}}}},x:{ type: terms,field: resource, facet: {y: {  type: terms, field: repo,facet: {  eventCount: \"sum(event_count)\"}}}}}";
-
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    String startTime = searchCriteria.getStartTime();
-    String endTime = searchCriteria.getEndTime();
+  public Response export(UserExportRequest request) throws TemplateException {
+    String startTime = request.getFrom();
+    String endTime = request.getTo();
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
 
     startTime = startTime == null ? "" : startTime;
     endTime = endTime == null ? "" : "_" + endTime;
 
-    SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
-    SolrUtil.setRowCount(solrQuery, 0);
-
-    String dataFormat = searchCriteria.getFormat();
+    String dataFormat = request.getFormat();
 
     FileOutputStream fis = null;
     try {
-      QueryResponse queryResponse = auditSolrDao.process(solrQuery);
+      QueryResponse queryResponse = auditSolrDao.process(facetQuery);
       if (queryResponse == null) {
         VResponse response = new VResponse();
-        response.setMsgDesc("Query was not able to execute " + solrQuery);
+        response.setMsgDesc("Query was not able to execute " + facetQuery);
         throw RESTErrorUtil.createRESTException(response);
       }
-
-      NamedList<Object> namedList = queryResponse.getResponse();
-      if (namedList == null) {
-        VResponse response = new VResponse();
-        response.setMsgDesc("Query was not able to execute " + solrQuery);
-        throw RESTErrorUtil.createRESTException(response);
-      }
-      BarGraphDataListResponse vBarUserDataList = new BarGraphDataListResponse();
-      BarGraphDataListResponse vBarResourceDataList = new BarGraphDataListResponse();
-
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
-      vBarUserDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
-      vBarResourceDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "y", "x");
+      BarGraphDataListResponse vBarUserDataList = graphDataGenerator.generateSecondLevelBarGraphDataResponse(queryResponse, 0);
+      BarGraphDataListResponse vBarResourceDataList = graphDataGenerator.generateSecondLevelBarGraphDataResponse(queryResponse, 1);
       String data = "";
-      String summary = "";
       if ("text".equals(dataFormat)) {
-        int users = 0;
-        int resources = 0;
-        summary += "\n\n\n\n";
-        data += addBlank("Users") + "Components/Access" + "\n";
-        data += "--------------------------------------------------------------------------\n";
-        Collection<BarGraphData> tableUserData = vBarUserDataList.getGraphData();
-        for (BarGraphData graphData : tableUserData) {
-          String userName = graphData.getName();
-          String largeUserName = "";
-
-          if (userName.length() > 45) {
-            largeUserName = userName.substring(0, 45);
-            data += addBlank(largeUserName);
-          } else
-            data += addBlank(userName);
-
-          Collection<NameValueData> vnameValueList = graphData.getDataCount();
-          data = appendNameValueData(data, vnameValueList);
-          while (largeUserName.length() > 0) {
-            data += largeUserName.substring(0, 45) + "\n";
-          }
-
-          users += 1;
-        }
-        data += "\n\n\n\n\n\n";
-        data += addBlank("Resources") + "Components/Access" + "\n";
-        data += "--------------------------------------------------------------------------\n";
-        Collection<BarGraphData> tableResourceData = vBarResourceDataList.getGraphData();
-        for (BarGraphData graphData : tableResourceData) {
-          String resourceName = graphData.getName();
-          String largeResourceName = resourceName;
-          if (largeResourceName.length() > 45) {
-            resourceName = largeResourceName.substring(0, 45);
-            largeResourceName = largeResourceName.substring(45, largeResourceName.length());
-          } else {
-            largeResourceName = "";
-          }
+        StringWriter stringWriter = new StringWriter();
+        Template template = freemarkerConfiguration.getTemplate(AUDIT_LOG_TEMPLATE);
+        Map<String, Object> models = new HashMap<>();
+        DownloadUtil.fillUserResourcesModel(models, vBarUserDataList, vBarResourceDataList);
+        template.process(models, stringWriter);
+        data = stringWriter.toString();
 
-          //resourceName = resourceName.replaceAll("(.{45})", resourceName.substring(0, 45)+"\n");
-          data += addBlank(resourceName);
-          Collection<NameValueData> vnameValueList = graphData.getDataCount();
-          data = appendNameValueData(data, vnameValueList);
-          String tempLargeResourceName = largeResourceName;
-          while (largeResourceName.length() > 45) {
-            largeResourceName = tempLargeResourceName.substring(0, 45);
-            tempLargeResourceName = tempLargeResourceName.substring(45, tempLargeResourceName.length());
-            data += largeResourceName + "\n";
-          }
-          if (largeResourceName.length() < 45 && !largeResourceName.isEmpty()) {
-            data += largeResourceName + "\n";
-          }
-          resources += 1;
-        }
-        String header = "--------------------------------SUMMARY-----------------------------------\n";
-        summary = header + "Users  = " + users + "\nResources  = " + resources + "\n" + summary;
-        data = summary + data;
       } else {
         data = "{" + convertObjToString(vBarUserDataList) + "," + convertObjToString(vBarResourceDataList) + "}";
         dataFormat = "json";
       }
       String fileName = "Users_Resource" + startTime + endTime + ".";
       File file = File.createTempFile(fileName, dataFormat);
-
       fis = new FileOutputStream(file);
       fis.write(data.getBytes());
       return Response
@@ -419,8 +172,8 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
         .header("Content-Disposition", "attachment;filename=" + fileName + dataFormat)
         .build();
 
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error("Error during solrQuery=" + e);
+    } catch (IOException e) {
+      logger.error("Error during download file (audit log) " + e);
       throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     } finally {
       if (fis != null) {
@@ -432,97 +185,6 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
     }
   }
 
-  private BarGraphDataListResponse getGraphResponse(BarGraphDataListResponse dataList, SolrQuery solrQuery,
-                                                    List<BarGraphData> histogramData, String jsonHistogramQuery) {
-    try {
-      SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
-      SolrUtil.setRowCount(solrQuery, 0);
-      QueryResponse response = auditSolrDao.process(solrQuery);
-      if (response == null) {
-        return dataList;
-      }
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-
-      if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
-        return dataList;
-      }
-
-      auditSolrDao.extractValuesFromBuckets(jsonFacetResponse, "x", "y", histogramData);
-
-      dataList.setGraphData(histogramData);
-      return dataList;
-
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error(e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-
-    }
-  }
-
-  private String appendNameValueData(String data, Collection<NameValueData> vnameValueList) {
-    int count = 0;
-    String blank = "";
-    for (NameValueData vNameValue : vnameValueList) {
-      data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
-      if (count == 0)
-        blank = addBlank(blank);
-      count++;
-    }
-    return data;
-  }
-
-  private String addBlank(String field) {
-    int blanks = 50;
-    int strSize = field.length();
-    String fieldWithBlank = field;
-    for (int i = 0; i < blanks - strSize; i++) {
-      fieldWithBlank += " ";
-    }
-    return fieldWithBlank;
-  }
-
-  public BarGraphDataListResponse getServiceLoad(CommonSearchCriteria searchCriteria) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    Collection<BarGraphData> vaDatas = new ArrayList<BarGraphData>();
-    dataList.setGraphData(vaDatas);
-
-    SolrQuery serivceLoadQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
-    try {
-      SolrUtil.setFacetField(serivceLoadQuery, LogSearchConstants.AUDIT_COMPONENT);
-      QueryResponse serviceLoadResponse = auditSolrDao.process(serivceLoadQuery);
-      if (serviceLoadResponse == null) {
-        return dataList;
-      }
-      FacetField serviceFacetField = serviceLoadResponse.getFacetField(LogSearchConstants.AUDIT_COMPONENT);
-      if (serviceFacetField == null) {
-        return dataList;
-      }
-
-      List<Count> serviceLoadFacets = serviceFacetField.getValues();
-      if (serviceLoadFacets == null) {
-        return dataList;
-      }
-      for (Count cnt : serviceLoadFacets) {
-        List<NameValueData> valueList = new ArrayList<NameValueData>();
-        BarGraphData vBarGraphData = new BarGraphData();
-        vaDatas.add(vBarGraphData);
-        NameValueData vNameValue = new NameValueData();
-        vNameValue.setName(cnt.getName());
-        vBarGraphData.setName(cnt.getName().toUpperCase());
-        vNameValue.setValue("" + cnt.getCount());
-        valueList.add(vNameValue);
-        vBarGraphData.setDataCount(valueList);
-      }
-
-      return dataList;
-
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-  }
-
   @Override
   protected List<SolrAuditLogData> convertToSolrBeans(QueryResponse response) {
     return response.getBeans(SolrAuditLogData.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java
index 13df470..a7b9cb5 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java
@@ -28,17 +28,13 @@ import java.util.Date;
 import java.util.List;
 import java.util.Scanner;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.MessageEnums;
 import org.apache.ambari.logsearch.model.response.LogData;
 import org.apache.ambari.logsearch.model.response.LogSearchResponse;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
 import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.query.QueryGeneration;
 import org.apache.ambari.logsearch.util.DateUtil;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
@@ -46,30 +42,13 @@ import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrException;
-
-import javax.inject.Inject;
+import org.springframework.data.solr.core.DefaultQueryParser;
+import org.springframework.data.solr.core.query.SimpleQuery;
+import org.springframework.data.solr.core.query.SolrDataQuery;
 
 public abstract class ManagerBase<LOG_DATA_TYPE extends LogData, SEARCH_RESPONSE extends LogSearchResponse> extends JsonManagerBase {
   private static final Logger logger = Logger.getLogger(ManagerBase.class);
 
-  @Inject
-  protected QueryGeneration queryGenerator;
-
-  public enum LogType {
-    SERVICE("Service"),
-    AUDIT("Audit");
-    
-    private String label;
-    
-    private LogType(String label) {
-      this.label = label;
-    }
-    
-    public String getLabel() {
-      return label;
-    }
-  }
-
   public ManagerBase() {
     super();
   }
@@ -103,77 +82,52 @@ public abstract class ManagerBase<LOG_DATA_TYPE extends LogData, SEARCH_RESPONSE
 
   }
   
-  protected SEARCH_RESPONSE getLastPage(SearchCriteria searchCriteria, String logTimeField, SolrDaoBase solrDoaBase,
-                                    SolrQuery lastPageQuery) {
-    
-    Integer maxRows = searchCriteria.getMaxRows();
-    String givenSortType = searchCriteria.getSortType();
-    searchCriteria = new SearchCriteria();
-    searchCriteria.setSortBy(logTimeField);
-    if (givenSortType == null || givenSortType.equals(LogSearchConstants.DESCENDING_ORDER)) {
-      lastPageQuery.removeSort(LogSearchConstants.LOGTIME);
-      searchCriteria.setSortType(LogSearchConstants.ASCENDING_ORDER);
-    } else {
-      searchCriteria.setSortType(LogSearchConstants.DESCENDING_ORDER);
-    }
-    queryGenerator.setSingleSortOrder(lastPageQuery, searchCriteria);
-
-
-    Long totalLogs = 0l;
-    int startIndex = 0;
-    int numberOfLogsOnLastPage = 0;
-    SEARCH_RESPONSE logResponse = null;
-    try {
-      SolrUtil.setStart(lastPageQuery, 0);
-      SolrUtil.setRowCount(lastPageQuery, maxRows);
-      logResponse = getLogAsPaginationProvided(lastPageQuery, solrDoaBase);
-      totalLogs = countQuery(lastPageQuery,solrDoaBase);
-      startIndex = Integer.parseInt("" + ((totalLogs / maxRows) * maxRows));
-      numberOfLogsOnLastPage = Integer.parseInt("" + (totalLogs - startIndex));
-      logResponse.setStartIndex(startIndex);
-      logResponse.setTotalCount(totalLogs);
-      logResponse.setPageSize(maxRows);
-      List<LOG_DATA_TYPE> docList = logResponse.getLogList();
-      List<LOG_DATA_TYPE> lastPageDocList = new ArrayList<>();
-      logResponse.setLogList(lastPageDocList);
-      int cnt = 0;
-      for(LOG_DATA_TYPE doc:docList){
-        if(cnt<numberOfLogsOnLastPage){
-          lastPageDocList.add(doc);
-        }
-        cnt++;
+  protected SEARCH_RESPONSE getLastPage(SolrDaoBase solrDoaBase, SimpleQuery lastPageQuery, String event) {
+    int maxRows = lastPageQuery.getRows();
+    SEARCH_RESPONSE logResponse = getLogAsPaginationProvided(lastPageQuery, solrDoaBase, event);
+    Long totalLogs = solrDoaBase.count(lastPageQuery);
+    int startIndex = Integer.parseInt("" + ((totalLogs / maxRows) * maxRows));
+    int numberOfLogsOnLastPage = Integer.parseInt("" + (totalLogs - startIndex));
+    logResponse.setStartIndex(startIndex);
+    logResponse.setTotalCount(totalLogs);
+    logResponse.setPageSize(maxRows);
+    List<LOG_DATA_TYPE> docList = logResponse.getLogList();
+    List<LOG_DATA_TYPE> lastPageDocList = new ArrayList<>();
+    logResponse.setLogList(lastPageDocList);
+    int cnt = 0;
+    for (LOG_DATA_TYPE doc : docList) {
+      if (cnt < numberOfLogsOnLastPage) {
+        lastPageDocList.add(doc);
       }
-      Collections.reverse(lastPageDocList);
-
-    } catch (SolrException | SolrServerException | IOException | NumberFormatException e) {
-      logger.error("Count Query was not executed successfully",e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      cnt++;
     }
+    Collections.reverse(lastPageDocList);
     return logResponse;
   }
 
-  protected SEARCH_RESPONSE getLogAsPaginationProvided(SolrQuery solrQuery, SolrDaoBase solrDaoBase) {
-    try {
-      QueryResponse response = solrDaoBase.process(solrQuery);
-      SEARCH_RESPONSE logResponse = createLogSearchResponse();
-      SolrDocumentList docList = response.getResults();
-      List<LOG_DATA_TYPE> serviceLogDataList = convertToSolrBeans(response);
-      if (docList != null && !docList.isEmpty()) {
-        logResponse.setLogList(serviceLogDataList);
-        logResponse.setStartIndex((int) docList.getStart());
-        logResponse.setTotalCount(docList.getNumFound());
-        Integer rowNumber = solrQuery.getRows();
-        if (rowNumber == null) {
-          logger.error("No RowNumber was set in solrQuery");
-          return createLogSearchResponse();
-        }
-        logResponse.setPageSize(rowNumber);
+  protected SEARCH_RESPONSE getLogAsPaginationProvided(SolrDataQuery solrQuery, SolrDaoBase solrDaoBase, String event) {
+    SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(solrQuery);
+    return getLogAsPaginationProvided(query, solrDaoBase, event);
+  }
+
+
+  protected SEARCH_RESPONSE getLogAsPaginationProvided(SolrQuery solrQuery, SolrDaoBase solrDaoBase, String event) {
+    QueryResponse response = solrDaoBase.process(solrQuery, event);
+    SEARCH_RESPONSE logResponse = createLogSearchResponse();
+    SolrDocumentList docList = response.getResults();
+    List<LOG_DATA_TYPE> serviceLogDataList = convertToSolrBeans(response);
+    if (docList != null && !docList.isEmpty()) {
+      logResponse.setLogList(serviceLogDataList);
+      logResponse.setStartIndex((int) docList.getStart());
+      logResponse.setTotalCount(docList.getNumFound());
+      Integer rowNumber = solrQuery.getRows();
+      if (rowNumber == null) {
+        logger.error("No RowNumber was set in solrQuery");
+        return createLogSearchResponse();
       }
-      return logResponse;
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      logResponse.setPageSize(rowNumber);
     }
+    return logResponse;
   }
   
   protected Long countQuery(SolrQuery query,SolrDaoBase solrDaoBase) throws SolrException, SolrServerException, IOException {
@@ -189,13 +143,6 @@ public abstract class ManagerBase<LOG_DATA_TYPE extends LogData, SEARCH_RESPONSE
     return docList.getNumFound();
   }
 
-  protected String getUnit(String unit) {
-    if (StringUtils.isBlank(unit)) {
-      unit = "+1HOUR";
-    }
-    return unit;
-  }
-
   protected String getFrom(String from) {
     if (StringUtils.isBlank(from)) {
       Date date = DateUtil.getTodayFromDate();

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea644cc4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
index 82817d6..cbab651 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
@@ -25,11 +25,11 @@ import java.util.List;
 import org.apache.ambari.logsearch.conf.AuthPropsConfig;
 import org.apache.ambari.logsearch.model.response.NameValueData;
 import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
+@Named
 public class PublicManager extends JsonManagerBase {
 
   @Inject