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);
+  }
+}

Reply via email to