本文整理汇总了Java中org.alfresco.service.cmr.search.SearchParameters.setStats方法的典型用法代码示例。如果您正苦于以下问题:Java SearchParameters.setStats方法的具体用法?Java SearchParameters.setStats怎么用?Java SearchParameters.setStats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.search.SearchParameters
的用法示例。
在下文中一共展示了SearchParameters.setStats方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBuildStats
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildStats() throws UnsupportedEncodingException
{
SearchParameters params = new SearchParameters();
params.setSearchTerm("bob");
params.setStats(Arrays.asList(
new StatsRequestParameters("created", null, null, null, null,null, null, null, null,
null, null, null, null,null, null, null),
new StatsRequestParameters("cm:name", "statLabel",
Arrays.asList(2.4f, 99.9f),null, null, false, null,false, null, false, null, true, true,
true, 0.5f, Arrays.asList("excludeme"))));
StringBuilder urlBuilder = new StringBuilder();
client.buildStatsParameters(params, encoder, urlBuilder);
String url = urlBuilder.toString();
assertNotNull(url);
assertTrue(url.contains("&stats=true"));
assertTrue(url.contains("stats.field=" + encoder.encode(
"{! countDistinct=false distinctValues=false min=true max=true sum=true count=true missing=true sumOfSquares=true mean=true stddev=true}created", "UTF-8")));
assertTrue(url.contains("stats.field=" + encoder.encode(
"{! ex=excludeme tag=statLabel key=statLabel percentiles='2.4,99.9' cardinality=0.5 countDistinct=true distinctValues=true min=true max=true sum=false count=true missing=false sumOfSquares=true mean=false stddev=true}cm:name", "UTF-8")));
}
示例2: testBuildPivots
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildPivots() throws UnsupportedEncodingException
{
SearchParameters params = new SearchParameters();
params.setSearchTerm("bob");
params.addPivots(Arrays.asList("creator"));
params.setStats(Arrays.asList(
new StatsRequestParameters("created", "piv1", null, null, null,null, null, null, null,
null, null, null, null,null, null, null)
));
List<RangeParameters> ranges = new ArrayList<RangeParameters>();
ranges.add(new RangeParameters("content.size","0","1000000", "10000", true, Collections.emptyList(), Collections.emptyList(), "csize",null));
params.setRanges(ranges);
StringBuilder urlBuilder = new StringBuilder();
client.buildPivotParameters(params, encoder, urlBuilder);
String url = urlBuilder.toString();
assertNotNull(url);
assertTrue(url.contains("&facet=true"));
assertTrue(url.contains("facet.pivot=creator"));
params.addPivots(Arrays.asList("cm:name", "piv1", "csize"));
urlBuilder = new StringBuilder();
client.buildPivotParameters(params, encoder, urlBuilder);
url = urlBuilder.toString();
assertNotNull(url);
assertTrue(url.contains("&facet=true"));
assertTrue(url.contains("facet.pivot="+ encoder.encode("creator", "UTF-8")));
assertTrue(url.contains("facet.pivot="+ encoder.encode("{! stats=piv1 range=csize}cm:name", "UTF-8")));
}
示例3: fromStats
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
public void fromStats(SearchParameters sp, List<StatsRequestParameters> stats)
{
if (stats != null && !stats.isEmpty())
{
for (StatsRequestParameters aStat:stats)
{
ParameterCheck.mandatory("stats field", aStat.getField());
List<Float> perc = aStat.getPercentiles();
if (perc != null && !perc.isEmpty())
{
for (Float percentile:perc)
{
if (percentile == null || percentile < 0 || percentile > 100)
{
throw new IllegalArgumentException("Invalid percentile "+percentile);
}
}
}
if (aStat.getCardinality() && (aStat.getCardinalityAccuracy() < 0 || aStat.getCardinalityAccuracy() > 1))
{
throw new IllegalArgumentException("Invalid cardinality accuracy "+aStat.getCardinalityAccuracy() + " It must be between 0 and 1.");
}
}
sp.setStats(stats);
}
}