当前位置: 首页>>代码示例>>Java>>正文


Java StatsParameters类代码示例

本文整理汇总了Java中org.alfresco.service.cmr.search.StatsParameters的典型用法代码示例。如果您正苦于以下问题:Java StatsParameters类的具体用法?Java StatsParameters怎么用?Java StatsParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StatsParameters类属于org.alfresco.service.cmr.search包,在下文中一共展示了StatsParameters类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: query

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
@Override
public StatsResultSet query(StatsParameters searchParameters)
{
    searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    
    LuceneQueryLanguageSPI language = searcher.getQueryLanguages().get(searchParameters.getLanguage().toLowerCase());
    if (language != null && SearchService.LANGUAGE_SOLR_FTS_ALFRESCO.equals(language.getName()))
    {
        SolrQueryLanguage solr = (SolrQueryLanguage) language;
        return solr.executeStatsQuery(searchParameters);
    }
    else
    {
        throw new SearcherException("Unknown stats query language: " + searchParameters.getLanguage());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:SolrStatsService.java

示例2: buildStatsUrl

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
protected String buildStatsUrl(StatsParameters searchParameters, String baseUrl, Locale locale, SolrStoreMappingWrapper mapping) throws UnsupportedEncodingException
{
    URLCodec encoder = new URLCodec();
    StringBuilder url = new StringBuilder();
    String languageUrlFragment = extractLanguageFragment(searchParameters.getLanguage());
    
    url.append(baseUrl);
    url.append("/").append(languageUrlFragment);
    url.append("?wt=").append(encoder.encode("json", "UTF-8"));
    url.append("&locale=").append(encoder.encode(locale.toString(), "UTF-8"));
    
    url.append(buildSortParameters(searchParameters, encoder));
    
    url.append("&stats=true");
    url.append("&rows=0");
    if (!StringUtils.isBlank(searchParameters.getFilterQuery()))
    {
        url.append("?fq=").append(encoder.encode(searchParameters.getFilterQuery(), "UTF-8")); 
    }

    for(Entry<String, String> entry : searchParameters.getStatsParameters().entrySet())
    {
        url.append("&stats.").append(entry.getKey()).append("=").append(encoder.encode(entry.getValue(), "UTF-8"));
    }
    
    if((mapping != null) && ((searchParameters.getStores().size() > 1) || (mapping.isSharded())))
    {
        url.append("&shards=");
        buildShards(url, searchParameters.getStores());
    }
    
    return url.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:34,代码来源:SolrQueryHTTPClient.java

示例3: buildStatsBody

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
protected JSONObject buildStatsBody(StatsParameters searchParameters, String tenant, Locale locale) throws JSONException
{
    JSONObject body = new JSONObject();
    body.put("query", searchParameters.getQuery());
    
    JSONArray tenants = new JSONArray();
    tenants.put(tenant);
    body.put("tenants", tenants);
    
    JSONArray locales = new JSONArray();
    locales.put(locale);
    body.put("locales", locales);
    
    return body;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:SolrQueryHTTPClient.java

示例4: testBuildStatsUrl

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
@Test
public void testBuildStatsUrl() throws UnsupportedEncodingException
{
    StatsParameters params = getParameters();
    String url = client.buildStatsUrl(params, "http://localhost:8080/solr/alfresco/select", Locale.CANADA_FRENCH, null);
    assertNotNull(url);
    assertTrue(url.contains("locale=fr_CA"));
    assertTrue(url.contains("sort=contentsize"));
    assertTrue(url.contains("fq=ANCESTOR"));

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:SolrQueryHTTPClientTest.java

示例5: testBuildStatsBody

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
@Test
public void testBuildStatsBody() throws JSONException
{

    StatsParameters params = getParameters();
    JSONObject body = client.buildStatsBody(params, "myTenant", Locale.US);
    assertNotNull(body);
    JSONArray tenant = body.getJSONArray("tenants");
    assertEquals("myTenant", tenant.get(0).toString());
    JSONArray locale = body.getJSONArray("locales");
    assertEquals("en_US", locale.get(0).toString());
    String query = body.getString("query");
    assertTrue(query.contains("TYPE:"));
    assertTrue(query.contains("{http://www.alfresco.org/model/content/1.0}content"));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:SolrQueryHTTPClientTest.java

示例6: getParameters

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
private StatsParameters getParameters()
{

    StringBuilder luceneQuery = new StringBuilder();
    luceneQuery.append(" +TYPE:\"" + ContentModel.TYPE_CONTENT + "\"");
    String filterQuery = "ANCESTOR:\"workspace://SpacesStore/a1c1a0a1-9d68-4912-b853-b3b277f31288\"";
    StatsParameters params = new StatsParameters(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO, luceneQuery.toString(), filterQuery, false);
    params.addSort(new SortDefinition(SortDefinition.SortType.FIELD, "contentsize", false));
    params.addStatsParameter(StatsParameters.PARAM_FIELD, "contentsize");
    params.addStatsParameter(StatsParameters.PARAM_FACET, StatsParameters.FACET_PREFIX + ContentModel.PROP_CREATED.toString());
    params.addStatsParameter("Test1", StatsParameters.FACET_PREFIX + "author. .u");
    params.addStatsParameter("Test2", StatsParameters.FACET_PREFIX + "creator. .u");
    return params;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:SolrQueryHTTPClientTest.java

示例7: testBuildStatsUrl

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
@Test
public void testBuildStatsUrl() throws UnsupportedEncodingException
{
    SolrQueryHTTPClient client = new SolrQueryHTTPClient();
    client.setLanguageMappings(languageMappings);
    StatsParameters params = getParameters();
    String url = client.buildStatsUrl(params, "http://localhost:8080/solr/alfresco/select", Locale.CANADA_FRENCH, null);
    assertNotNull(url);
    assertTrue(url.contains("locale=fr_CA"));
    assertTrue(url.contains("sort=contentsize"));
    assertTrue(url.contains("fq=ANCESTOR"));

}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:14,代码来源:SolrQueryHTTPClientTest.java

示例8: testBuildStatsBody

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
@Test
public void testBuildStatsBody() throws JSONException
{
    SolrQueryHTTPClient client = new SolrQueryHTTPClient();
    StatsParameters params = getParameters();
    JSONObject body = client.buildStatsBody(params, "myTenant", Locale.US);
    assertNotNull(body);
    JSONArray tenant = body.getJSONArray("tenants");
    assertEquals("myTenant",tenant.get(0).toString());
    JSONArray locale = body.getJSONArray("locales");
    assertEquals("en_US",locale.get(0).toString());
    String query = body.getString("query");
    assertTrue(query.contains("TYPE:"));
    assertTrue(query.contains("{http://www.alfresco.org/model/content/1.0}content"));
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:16,代码来源:SolrQueryHTTPClientTest.java

示例9: getParameters

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
private StatsParameters getParameters() {

        StringBuilder luceneQuery = new StringBuilder();
        luceneQuery.append(" +TYPE:\"" + ContentModel.TYPE_CONTENT + "\"");
        
        String filterQuery = "ANCESTOR:\"workspace://SpacesStore/a1c1a0a1-9d68-4912-b853-b3b277f31288\"";
        StatsParameters params = new StatsParameters(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO, luceneQuery.toString(), filterQuery, false);
        params.addSort(new SortDefinition(SortDefinition.SortType.FIELD, "contentsize", false));
        params.addStatsParameter(StatsParameters.PARAM_FIELD, "contentsize");
        params.addStatsParameter(StatsParameters.PARAM_FACET, StatsParameters.FACET_PREFIX+ContentModel.PROP_CREATED.toString());
        params.addStatsParameter("Test1", StatsParameters.FACET_PREFIX+"author. .u");
        params.addStatsParameter("Test2", StatsParameters.FACET_PREFIX+"creator. .u");
        return params;
    }
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:15,代码来源:SolrQueryHTTPClientTest.java

示例10: executeStatsQuery

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
/**
 * Executes a stats query using solr.
 * @param searchParameters StatsParameters
 * @return StatsResultSet
 */
public StatsResultSet executeStatsQuery(StatsParameters searchParameters)
{
   return solrQueryHTTPClient.executeStatsQuery( searchParameters);

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:SolrQueryLanguage.java

示例11: executeImpl

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) 
{
   Map<String, Object> model = new HashMap<String, Object>(2, 1.0f);
   Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
   SiteInfo siteInfo = null;
   
   String listFacets = req.getParameter("listFacets");
   if (listFacets != null)
   {
       model.put("facets", facets.keySet());
       model.put("resultSize", 0);
       return model;
   }
   
   if (templateVars != null && templateVars.containsKey("siteId") )
   {
     siteInfo = siteService.getSite(templateVars.get("siteId"));
     if (siteInfo == null)
     {
         throw new AccessDeniedException("No such site: " + templateVars.get("siteId"));
     }
   }

   String facetKey = req.getParameter("facet");
   if (facetKey == null) facetKey = facets.entrySet().iterator().next().getKey();  //default
   String query;
   
   QName propFacet = findFacet(facetKey);
   Pair<LocalDate, LocalDate> startAndEnd = getStartAndEndDates(req.getParameter("startDate"),req.getParameter("endDate"));
   query = buildQuery(siteInfo, facetKey, startAndEnd);

   StatsParameters params = new StatsParameters(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO, query, false);
   //params.addSort(new SortDefinition(SortDefinition.SortType.FIELD, this.statsField, false));
   params.addStatsParameter(StatsParameters.PARAM_FIELD, this.statsField);
   params.addStatsParameter(StatsParameters.PARAM_FACET, StatsParameters.FACET_PREFIX+propFacet.toString());
  
   StatsResultSet result = stats.query(params);
   
   if (postProcessors.containsKey(facetKey))
   {
       StatsProcessor processor = postProcessors.get(facetKey);
       result = processor.process(result);
   }
   model.put("result", result);
   model.put("resultSize", result.getStats().size());
   return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:49,代码来源:StatsGet.java

示例12: buildStatsUrl

import org.alfresco.service.cmr.search.StatsParameters; //导入依赖的package包/类
protected String buildStatsUrl(StatsParameters searchParameters, String baseUrl, Locale locale, SolrStoreMappingWrapper mapping) throws UnsupportedEncodingException
{
    URLCodec encoder = new URLCodec();
    StringBuilder url = new StringBuilder();
    String languageUrlFragment = extractLanguageFragment(searchParameters.getLanguage());
    
    url.append(baseUrl);
    url.append("/").append(languageUrlFragment);
    url.append("?wt=").append(encoder.encode("json", "UTF-8"));
    url.append("&locale=").append(encoder.encode(locale.toString(), "UTF-8"));
    
    url.append(buildSortParameters(searchParameters, encoder));
    
    url.append("&stats=true");
    url.append("&rows=0");
    if (!StringUtils.isBlank(searchParameters.getFilterQuery()))
    {
        url.append("?fq=").append(encoder.encode(searchParameters.getFilterQuery(), "UTF-8")); 
    }

    for(Entry<String, String> entry : searchParameters.getStatsParameters().entrySet())
    {
        url.append("&stats.").append(entry.getKey()).append("=").append(encoder.encode(entry.getValue(), "UTF-8"));
    }
    
    if((mapping != null) && ((searchParameters.getStores().size() > 1) || (mapping.isSharded())))
    {
        boolean requiresSeparator = false;
        url.append("&shards=");
        for(StoreRef storeRef : searchParameters.getStores())
        {
            SolrStoreMappingWrapper storeMapping = extractMapping(storeRef);

            if(requiresSeparator)
            {
                url.append(',');
            }
            else
            {
                requiresSeparator = true;
            }

            url.append(storeMapping.getShards());
           
        }
    }
    
    return url.toString();
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:50,代码来源:SolrQueryHTTPClient.java


注:本文中的org.alfresco.service.cmr.search.StatsParameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。