use of org.alfresco.repo.search.impl.lucene.SolrStatsResult in project alfresco-repository by Alfresco.
the class SolrStatsResultTest method testProcessing.
private SolrStatsResult testProcessing(String testData, long queryTime, int statsSize, long numberFound) throws JSONException {
JSONObject json = new JSONObject(new JSONTokener(testData));
SolrStatsResult result = new SolrStatsResult(json, false);
assertNotNull(result);
assertEquals(numberFound, result.getNumberFound());
assertTrue(result.getStatus() == 0);
assertTrue(result.getQueryTime() == queryTime);
assertTrue(result.getSum() == 14742886);
assertTrue(result.getMax() == 3737049);
assertTrue(result.getMean() == 82362);
assertEquals(statsSize, result.getStats().size());
return result;
}
use of org.alfresco.repo.search.impl.lucene.SolrStatsResult in project alfresco-repository by Alfresco.
the class SolrStatsResultTest method testSolrStatsResult.
@Test
public void testSolrStatsResult() throws JSONException {
SolrStatsResult resultCreated = testProcessing(TEST_CREATED, 13, 7, 188);
SolrStatsResult resultMimetype = testProcessing(TEST_MIMETYPE, 12, 11, 188);
SolrStatsResult resultCreator = testProcessing(TEST_CREATOR, 7, 4, 188);
SolrStatsResult resultMod = testProcessing(TEST_MODIFIER, 9, 4, 188);
SolrStatsResult resultV = testProcessing(TEST_VERSIONLABEL_DOT, 6, 0, 190);
}
use of org.alfresco.repo.search.impl.lucene.SolrStatsResult in project alfresco-repository by Alfresco.
the class SolrQueryHTTPClient method executeStatsQuery.
/**
* Executes a solr query for statistics
*
* @param searchParameters StatsParameters
* @return SolrStatsResult
*/
public SolrStatsResult executeStatsQuery(final StatsParameters searchParameters) {
if (repositoryState.isBootstrapping()) {
throw new AlfrescoRuntimeException("SOLR stats queries can not be executed while the repository is bootstrapping");
}
try {
StoreRef store = SolrClientUtil.extractStoreRef(searchParameters);
SolrStoreMappingWrapper mapping = SolrClientUtil.extractMapping(store, mappingLookup, shardRegistry, useDynamicShardRegistration, beanFactory);
Locale locale = SolrClientUtil.extractLocale(searchParameters);
Pair<HttpClient, String> httpClientAndBaseUrl = mapping.getHttpClientAndBaseUrl();
HttpClient httpClient = httpClientAndBaseUrl.getFirst();
String url = buildStatsUrl(searchParameters, httpClientAndBaseUrl.getSecond(), locale, mapping);
JSONObject body = buildStatsBody(searchParameters, tenantService.getCurrentUserDomain(), locale);
if (httpClient == null) {
throw new AlfrescoRuntimeException("No http client for store " + store.toString());
}
return (SolrStatsResult) postSolrQuery(httpClient, url, body, json -> {
return new SolrStatsResult(json, searchParameters.isDateSearch());
});
} catch (UnsupportedEncodingException e) {
throw new LuceneQueryParserException("stats", e);
} catch (HttpException e) {
throw new LuceneQueryParserException("stats", e);
} catch (IOException e) {
throw new LuceneQueryParserException("stats", e);
} catch (JSONException e) {
throw new LuceneQueryParserException("stats", e);
}
}
Aggregations