Search in sources :

Example 1 with SolrStatsResult

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;
}
Also used : JSONTokener(org.json.JSONTokener) JSONObject(org.json.JSONObject) SolrStatsResult(org.alfresco.repo.search.impl.lucene.SolrStatsResult)

Example 2 with SolrStatsResult

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);
}
Also used : SolrStatsResult(org.alfresco.repo.search.impl.lucene.SolrStatsResult) Test(org.junit.Test)

Example 3 with SolrStatsResult

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);
    }
}
Also used : Locale(java.util.Locale) SolrJsonProcessor(org.alfresco.repo.search.impl.lucene.SolrJsonProcessor) RangeParameters(org.alfresco.service.cmr.search.RangeParameters) URIException(org.apache.commons.httpclient.URIException) StringUtils(org.apache.commons.lang3.StringUtils) Header(org.apache.commons.httpclient.Header) DefaultTypeConverter(org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter) JSONResult(org.alfresco.repo.search.impl.lucene.JSONResult) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) PermissionService(org.alfresco.service.cmr.security.PermissionService) RepositoryState(org.alfresco.repo.admin.RepositoryState) NodeDAO(org.alfresco.repo.domain.node.NodeDAO) Locale(java.util.Locale) Map(java.util.Map) NodeService(org.alfresco.service.cmr.repository.NodeService) HttpStatus(org.apache.commons.httpclient.HttpStatus) ResultSet(org.alfresco.service.cmr.search.ResultSet) StatsParameters(org.alfresco.service.cmr.search.StatsParameters) QueryParserUtils(org.alfresco.repo.search.impl.QueryParserUtils) Set(java.util.Set) ShardRegistry(org.alfresco.repo.index.shard.ShardRegistry) Reader(java.io.Reader) CMISStrictDictionaryService(org.alfresco.opencmis.dictionary.CMISStrictDictionaryService) GetMethod(org.apache.commons.httpclient.methods.GetMethod) List(java.util.List) IntervalSet(org.alfresco.service.cmr.search.IntervalSet) I18NUtil(org.springframework.extensions.surf.util.I18NUtil) HttpClient(org.apache.commons.httpclient.HttpClient) Entry(java.util.Map.Entry) Optional(java.util.Optional) LogFactory(org.apache.commons.logging.LogFactory) URI(org.apache.commons.httpclient.URI) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LimitBy(org.alfresco.service.cmr.search.LimitBy) LuceneQueryParserException(org.alfresco.repo.search.impl.lucene.LuceneQueryParserException) Interval(org.alfresco.service.cmr.search.Interval) FieldFacet(org.alfresco.service.cmr.search.SearchParameters.FieldFacet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FieldFacetSort(org.alfresco.service.cmr.search.SearchParameters.FieldFacetSort) NamespaceDAO(org.alfresco.repo.dictionary.NamespaceDAO) ParameterCheck(org.alfresco.util.ParameterCheck) StatsRequestParameters(org.alfresco.service.cmr.search.StatsRequestParameters) HttpException(org.apache.commons.httpclient.HttpException) AuthorityType(org.alfresco.service.cmr.security.AuthorityType) StoreRef(org.alfresco.service.cmr.repository.StoreRef) Iterator(java.util.Iterator) FieldFacetMethod(org.alfresco.service.cmr.search.SearchParameters.FieldFacetMethod) SearchDateConversion.parseDateInterval(org.alfresco.util.SearchDateConversion.parseDateInterval) FieldHighlightParameters(org.alfresco.service.cmr.search.FieldHighlightParameters) HttpServletResponse(javax.servlet.http.HttpServletResponse) JSONTokener(org.json.JSONTokener) Pair(org.alfresco.util.Pair) IOException(java.io.IOException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) BeansException(org.springframework.beans.BeansException) InputStreamReader(java.io.InputStreamReader) TenantService(org.alfresco.repo.tenant.TenantService) BasicSearchParameters(org.alfresco.service.cmr.search.BasicSearchParameters) PermissionEvaluationMode(org.alfresco.service.cmr.search.PermissionEvaluationMode) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) SortDefinition(org.alfresco.service.cmr.search.SearchParameters.SortDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition) SolrStatsResult(org.alfresco.repo.search.impl.lucene.SolrStatsResult) URLCodec(org.apache.commons.codec.net.URLCodec) StringJoiner(java.util.StringJoiner) BeanFactory(org.springframework.beans.factory.BeanFactory) PropertyCheck(org.alfresco.util.PropertyCheck) Log(org.apache.commons.logging.Log) BufferedReader(java.io.BufferedReader) Floc(org.alfresco.repo.index.shard.Floc) SearchParameters(org.alfresco.service.cmr.search.SearchParameters) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) SolrJSONResultSet(org.alfresco.repo.search.impl.lucene.SolrJSONResultSet) JSONArray(org.json.JSONArray) StoreRef(org.alfresco.service.cmr.repository.StoreRef) SolrStatsResult(org.alfresco.repo.search.impl.lucene.SolrStatsResult) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JSONException(org.json.JSONException) IOException(java.io.IOException) JSONObject(org.json.JSONObject) LuceneQueryParserException(org.alfresco.repo.search.impl.lucene.LuceneQueryParserException) HttpClient(org.apache.commons.httpclient.HttpClient) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) HttpException(org.apache.commons.httpclient.HttpException)

Aggregations

SolrStatsResult (org.alfresco.repo.search.impl.lucene.SolrStatsResult)3 JSONObject (org.json.JSONObject)2 JSONTokener (org.json.JSONTokener)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Set (java.util.Set)1 StringJoiner (java.util.StringJoiner)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1