本文整理汇总了Java中org.alfresco.service.cmr.search.SearchParameters类的典型用法代码示例。如果您正苦于以下问题:Java SearchParameters类的具体用法?Java SearchParameters怎么用?Java SearchParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SearchParameters类属于org.alfresco.service.cmr.search包,在下文中一共展示了SearchParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
/**
* Execute the query
*
* Removes any duplicates that may be present (ID search can cause duplicates -
* it is better to remove them here)
*
* @param store StoreRef to search against - null for default configured store
* @param search Lucene search to execute
* @param sort Columns to sort by
* @param language Search language to use e.g. SearchService.LANGUAGE_LUCENE
* @param maxResults Maximum results to return if > 0
* @param skipResults Results to skip in the result set
*
* @return Array of Node objects
*/
protected Object[] query(String store, String search, SortColumn[] sort, String language, int maxResults, int skipResults)
{
SearchParameters sp = new SearchParameters();
sp.addStore(store != null ? new StoreRef(store) : this.storeRef);
sp.setLanguage(language != null ? language : SearchService.LANGUAGE_LUCENE);
sp.setQuery(search);
if (maxResults > 0)
{
sp.setLimit(maxResults);
sp.setLimitBy(LimitBy.FINAL_SIZE);
}
if (skipResults > 0)
{
sp.setSkipCount(skipResults);
}
if (sort != null)
{
for (SortColumn sd : sort)
{
sp.addSort(sd.column, sd.asc);
}
}
return query(sp, true);
}
示例2: fromSpellCheck
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
/**
* SearchParameters from SpellCheck object
* @param sp SearchParameters
* @param defaults SpellCheck
*/
public void fromSpellCheck(SearchParameters sp, Spelling spelling)
{
if (spelling != null)
{
if (spelling.getQuery() != null && !spelling.getQuery().isEmpty())
{
sp.setSearchTerm(spelling.getQuery());
}
else
{
if (sp.getSearchTerm() == null || sp.getSearchTerm().isEmpty())
{
//We don't have a valid search term to use with the spelling
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
new Object[] { ": userQuery or spelling.query required." });
}
}
sp.setSpellCheck(true);
}
}
示例3: fromRange
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
/**
* Sets the Range Parameters object on search parameters
* @param sp SearchParameters
* @param rangeParams RangeParameters
*/
public void fromRange(SearchParameters sp, List<RangeParameters> ranges)
{
if(ranges != null && !ranges.isEmpty())
{
for(RangeParameters rangeParams : ranges)
{
ParameterCheck.mandatory("ranges", rangeParams);
ParameterCheck.mandatory("field", rangeParams.getField());
ParameterCheck.mandatory("start", rangeParams.getStart());
ParameterCheck.mandatory("end", rangeParams.getEnd());
ParameterCheck.mandatory("gap", rangeParams.getGap());
}
sp.setRanges(ranges);
}
}
示例4: facetFormatV2
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
@Test
public void facetFormatV2()
{
Query query = new Query("afts", "a*", "");
SearchQuery sq = new SearchQuery(query, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null,
null, null,null, null,FacetFormat.V2);
SearchRequestContext searchRequestContext = SearchRequestContext.from(sq);
SearchParameters searchParameters = searchMapper.toSearchParameters(ResultMapperTests.EMPTY_PARAMS, sq, searchRequestContext);
assertNotNull(searchParameters);
//Test defaults
assertEquals("There should be only 1 default store", 1,searchParameters.getStores().size());
assertEquals("workspaces store is the default", StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, searchParameters.getStores().get(0));
assertEquals(LimitBy.FINAL_SIZE, searchParameters.getLimitBy());
assertEquals(100, searchParameters.getLimit());
}
示例5: query
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
public ResultSet query(StoreRef store, String language, String queryString, QueryParameterDefinition[] queryParameterDefinitions) throws SearcherException
{
store = tenantService.getName(store);
SearchParameters sp = new SearchParameters();
sp.addStore(store);
sp.setLanguage(language);
sp.setQuery(queryString);
if (queryParameterDefinitions != null)
{
for (QueryParameterDefinition qpd : queryParameterDefinitions)
{
sp.addQueryParameterDefinition(qpd);
}
}
sp.excludeDataInTheCurrentTransaction(true);
return query(sp);
}
示例6: testHighlight
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
@Test
public void testHighlight() throws Exception
{
SearchParameters sp = new SearchParameters();
sp.setBulkFetchEnabled(false);
GeneralHighlightParameters highlightParameters = new GeneralHighlightParameters(null,null,null,null,null,null,null,null);
sp.setHighlight(highlightParameters);
assertNull(sp.getHighlight().getMergeContiguous());
assertNull(sp.getHighlight().getFields());
List<FieldHighlightParameters> fields = new ArrayList<>(2);
fields.add(new FieldHighlightParameters(null, null, null, null, null,null));
fields.add(new FieldHighlightParameters("myfield", null, null, null, "(",")"));
highlightParameters = new GeneralHighlightParameters(1,2,null,null,null,50,true,fields);
sp.setHighlight(highlightParameters);
assertEquals(2,sp.getHighlight().getFields().size());
assertEquals(true,sp.getHighlight().getUsePhraseHighlighter().booleanValue());
assertEquals(1,sp.getHighlight().getSnippetCount().intValue());
assertEquals(50,sp.getHighlight().getMaxAnalyzedChars().intValue());
assertEquals(2,sp.getHighlight().getFragmentSize().intValue());
assertEquals("myfield",sp.getHighlight().getFields().get(1).getField());
assertEquals("(",sp.getHighlight().getFields().get(1).getPrefix());
assertEquals(")",sp.getHighlight().getFields().get(1).getPostfix());
}
示例7: prepareSearchParameters
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
@Override
protected SearchParameters prepareSearchParameters(final WebScriptRequest req, final NodeRef archiveContextNode, final int pageSize,
final int startIndex)
{
final SearchParameters sp = new SearchParameters();
sp.addStore(archiveContextNode.getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL_IF_POSSIBLE);
final StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("PARENT:\"").append(archiveContextNode).append("\"");
sp.setQuery(queryBuilder.toString());
sp.setSkipCount(startIndex);
sp.setLimit(pageSize);
sp.setMaxItems(pageSize);
return sp;
}
示例8: applyDecorations
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
@Override
public SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters,
VirtualQuery query) throws VirtualizationException
{
// TODO: allow custom language and not only constraint appliers
if (SearchService.LANGUAGE_FTS_ALFRESCO.equals(searchParameters.getLanguage()))
{
SearchParameters searchParametersCopy = searchParameters.copy();
return applyFTS(searchParametersCopy);
}
else
{
throw new VirtualizationException("Unsupported constrating language " + searchParameters.getLanguage());
}
}
示例9: applyDecorations
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
@Override
protected SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters,
VirtualQuery query)
{
if ((ignoreAspectQNames != null && !ignoreAspectQNames.isEmpty())
|| (ignoreTypeNames != null && !ignoreTypeNames.isEmpty()))
{
if (SearchService.LANGUAGE_FTS_ALFRESCO.equals(searchParameters.getLanguage()))
{
SearchParameters searchParametersCopy = searchParameters.copy();
return applyFTSDecorations(searchParametersCopy,
environment.getNamespacePrefixResolver());
}
else
{
throw new VirtualizationException("Unsupported constrating language " + searchParameters.getLanguage());
}
}
else
{
return searchParameters;
}
}
示例10: fromLimits
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
/**
* SearchParameters from the Limits object
* @param sp SearchParameters
* @param paging Paging
*/
public void fromLimits(SearchParameters sp, Limits limits)
{
if (limits != null)
{
if (limits.getPermissionEvaluationCount() != null)
{
sp.setLimit(-1);
sp.setLimitBy(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS);
sp.setMaxPermissionChecks(limits.getPermissionEvaluationCount());
}
if (limits.getPermissionEvaluationTime() != null)
{
sp.setLimit(-1);
sp.setLimitBy(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS);
sp.setMaxPermissionCheckTimeMillis(limits.getPermissionEvaluationTime());
}
}
}
示例11: apply
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
@Override
public SearchParameters apply(ActualEnvironment environment, VirtualQuery query) throws VirtualizationException
{
SearchParameters searchParameters = new SearchParameters();
String storeRefString = query.getStoreRef();
if (storeRefString != null)
{
searchParameters.addStore(new StoreRef(storeRefString));
}
else
{
searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
}
searchParameters.setLanguage(query.getLanguage());
searchParameters.setQuery(query.getQueryString());
searchParameters.setQueryConsistency(QueryConsistency.TRANSACTIONAL_IF_POSSIBLE);
return searchParameters;
}
示例12: 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")));
}
示例13: mockResultset
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
private ResultSet mockResultset(List<Long> archivedNodes, List<Long> versionNodes) throws JSONException
{
NodeService nodeService = mock(NodeService.class);
when(nodeService.getNodeRef(any())).thenAnswer(new Answer<NodeRef>() {
@Override
public NodeRef answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
//If the DBID is in the list archivedNodes, instead of returning a noderef return achivestore noderef
if (archivedNodes.contains(args[0])) return new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, GUID.generate());
if (versionNodes.contains(args[0])) return new NodeRef(StoreMapper.STORE_REF_VERSION2_SPACESSTORE, GUID.generate()+args[0]);
return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate());
}
});
SearchParameters sp = new SearchParameters();
sp.setBulkFetchEnabled(false);
JSONObject json = new JSONObject(new JSONTokener(JSON_REPONSE));
ResultSet results = new SolrJSONResultSet(json,sp,nodeService, null, LimitBy.FINAL_SIZE, 10);
return results;
}
示例14: assertPerform1Results
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
private void assertPerform1Results(Pair<QName, Boolean> withSortDefinitions)
{
ArgumentCaptor<SearchParameters> queryCaptor = ArgumentCaptor.forClass(SearchParameters.class);
Mockito.verify(mockitoActualEnvironment).query(queryCaptor.capture());
assertEquals("(QUERY_TEST_STRING_QUERY) and !ASPECT:'tst:testQName1' and !TYPE:'tst:testQName2'",
queryCaptor.getValue().getQuery());
ArrayList<SortDefinition> sortDefinitions = queryCaptor.getValue().getSortDefinitions();
assertNotNull(sortDefinitions);
assertEquals(1,
sortDefinitions.size());
assertEquals(withSortDefinitions.getFirst().getLocalName(),
sortDefinitions.get(0).getField());
assertEquals(withSortDefinitions.getSecond(),
Boolean.valueOf(sortDefinitions.get(0).isAscending()));
}
示例15: toSearchParameters
import org.alfresco.service.cmr.search.SearchParameters; //导入依赖的package包/类
@Test
public void toSearchParameters() throws Exception
{
SearchRequestContext searchRequest = SearchRequestContext.from(minimalQuery());
SearchParameters searchParameters = searchMapper.toSearchParameters(ResultMapperTests.EMPTY_PARAMS, minimalQuery(), searchRequest);
assertNotNull(searchParameters);
//Test defaults
assertEquals("There should be only 1 default store", 1,searchParameters.getStores().size());
assertEquals("workspaces store is the default", StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, searchParameters.getStores().get(0));
assertEquals(LimitBy.FINAL_SIZE, searchParameters.getLimitBy());
assertEquals(100, searchParameters.getLimit());
searchParameters = searchMapper.toSearchParameters(ResultMapperTests.EMPTY_PARAMS, helper.searchQueryFromJson(), searchRequest);
assertNotNull(searchParameters);
}