@Test public void testConvert() { ServiceGraphRequest request = new ServiceGraphQueryRequest(); fillBaseLogRequestWithTestData(request); request.setUnit("+1HOUR"); request.setLevel("WARN,ERROR,FATAL"); SolrQuery query = underTest.convert(request); assertEquals("?q=*%3A*&facet=true&facet.pivot=%7B%21range%3Dr1%7Dlevel&facet.mincount=1&facet.limit=-1" + "&facet.sort=index&facet.range=%7B%21tag%3Dr1%7Dlogtime&f.logtime.facet.range.start=2016-09-13T22%3A00%3A01.000Z" + "&f.logtime.facet.range.end=2016-09-14T22%3A00%3A01.000Z&f.logtime.facet.range.gap=%2B1HOUR&rows=0&start=0&fq=level%3A%28WARN+OR+ERROR+OR+FATAL%29&fq=cluster%3Acl1&fq=type%3A%28logsearch_app+OR+secure_log%29&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage", query.toQueryString()); }
@Override public SolrQuery convert(ServiceGraphRequest request) { SolrQuery solrQuery = super.convert(request); addListFilterToSolrQuery(solrQuery, LEVEL, request.getLevel()); if (request.getHostList() != null && StringUtils.isEmpty(request.getHostName())) { List<String> hosts = request.getHostList().length() == 0 ? Arrays.asList("\\-1") : splitValueAsList(request.getHostList(), ","); if (hosts.size() > 1) { solrQuery.addFilterQuery(String.format("%s:(%s)", HOST, StringUtils.join(hosts, " OR "))); } else { solrQuery.addFilterQuery(String.format("%s:%s", HOST, hosts.get(0))); } } addListFilterToSolrQuery(solrQuery, CLUSTER, request.getClusters()); addListFilterToSolrQuery(solrQuery, COMPONENT, request.getMustBe()); addIncludeFieldValues(solrQuery, request.getIncludeQuery()); addExcludeFieldValues(solrQuery, request.getExcludeQuery()); return solrQuery; }
ServiceLogLevelDateRangeRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<ServiceGraphRequest> { @Override public SolrQuery convert(ServiceGraphRequest request) { SolrQuery solrQuery = super.convert(request); addListFilterToSolrQuery(solrQuery, LEVEL, request.getLevel()); if (request.getHostList() != null && StringUtils.isEmpty(request.getHostName())) { List<String> hosts = request.getHostList().length() == 0 ? Arrays.asList("\\-1") : splitValueAsList(request.getHostList(), ","); if (hosts.size() > 1) { solrQuery.addFilterQuery(String.format("%s:(%s)", HOST, StringUtils.join(hosts, " OR "))); } else { solrQuery.addFilterQuery(String.format("%s:%s", HOST, hosts.get(0))); } } addListFilterToSolrQuery(solrQuery, CLUSTER, request.getClusters()); addListFilterToSolrQuery(solrQuery, COMPONENT, request.getMustBe()); addIncludeFieldValues(solrQuery, request.getIncludeQuery()); addExcludeFieldValues(solrQuery, request.getExcludeQuery()); return solrQuery; } }
ServiceLogLevelDateRangeRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<ServiceGraphRequest> { @Override public SolrQuery convert(ServiceGraphRequest request) { SolrQuery solrQuery = super.convert(request); addListFilterToSolrQuery(solrQuery, LEVEL, request.getLevel()); if (request.getHostList() != null && StringUtils.isEmpty(request.getHostName())) { List<String> hosts = request.getHostList().length() == 0 ? Arrays.asList("\\-1") : splitValueAsList(request.getHostList(), ","); if (hosts.size() > 1) { solrQuery.addFilterQuery(String.format("%s:(%s)", HOST, StringUtils.join(hosts, " OR "))); } else { solrQuery.addFilterQuery(String.format("%s:%s", HOST, hosts.get(0))); } } addListFilterToSolrQuery(solrQuery, CLUSTER, request.getClusters()); addListFilterToSolrQuery(solrQuery, COMPONENT, request.getMustBe()); addIncludeFieldValues(solrQuery, request.getIncludeQuery()); addExcludeFieldValues(solrQuery, request.getExcludeQuery()); return solrQuery; }  }
ServiceLogLevelDateRangeRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<ServiceGraphRequest> { @Override public SolrQuery convert(ServiceGraphRequest request) { SolrQuery solrQuery = super.convert(request); addListFilterToSolrQuery(solrQuery, LEVEL, request.getLevel()); if (request.getHostList() != null && StringUtils.isEmpty(request.getHostName())) { List<String> hosts = request.getHostList().length() == 0 ? Arrays.asList("\\-1") : splitValueAsList(request.getHostList(), ","); if (hosts.size() > 1) { solrQuery.addFilterQuery(String.format("%s:(%s)", HOST, StringUtils.join(hosts, " OR "))); } else { solrQuery.addFilterQuery(String.format("%s:%s", HOST, hosts.get(0))); } } addListFilterToSolrQuery(solrQuery, CLUSTER, request.getClusters()); addListFilterToSolrQuery(solrQuery, COMPONENT, request.getMustBe()); addIncludeFieldValues(solrQuery, request.getIncludeQuery()); addExcludeFieldValues(solrQuery, request.getExcludeQuery()); return solrQuery; }  @Override String getDateFieldName(); @Override String getTypeFieldName(); @Override SolrQuery convert(ServiceGraphRequest request); @Override LogType getLogType(); }
ServiceLogLevelDateRangeRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<ServiceGraphRequest> { @Override public SolrQuery convert(ServiceGraphRequest request) { SolrQuery solrQuery = super.convert(request); addListFilterToSolrQuery(solrQuery, LEVEL, request.getLevel()); if (request.getHostList() != null && StringUtils.isEmpty(request.getHostName())) { List<String> hosts = request.getHostList().length() == 0 ? Arrays.asList("\\-1") : splitValueAsList(request.getHostList(), ","); if (hosts.size() > 1) { solrQuery.addFilterQuery(String.format("%s:(%s)", HOST, StringUtils.join(hosts, " OR "))); } else { solrQuery.addFilterQuery(String.format("%s:%s", HOST, hosts.get(0))); } } addListFilterToSolrQuery(solrQuery, CLUSTER, request.getClusters()); addListFilterToSolrQuery(solrQuery, COMPONENT, request.getMustBe()); addIncludeFieldValues(solrQuery, request.getIncludeQuery()); addExcludeFieldValues(solrQuery, request.getExcludeQuery()); return solrQuery; }  @Override String getDateFieldName(); @Override String getTypeFieldName(); @Override SolrQuery convert(ServiceGraphRequest request); @Override LogType getLogType();  }