Skip to content

Instantly share code, notes, and snippets.

@rotty3000
Created December 18, 2012 17:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rotty3000/4329978 to your computer and use it in GitHub Desktop.
Save rotty3000/4329978 to your computer and use it in GitHub Desktop.
search for articles by tags
SearchContext searchContext = new SearchContext();
searchContext.setCompanyId(companyId);
// omit groups to search entire portal
searchContext.setGroupIds(new long[] {groupId});
// tags
searchContext.setAssetTagNames(assetTagNames);
// pagination?
searchContext.setEnd(end);
searchContext.setStart(start);
// makes it faster if you don't care about it
QueryConfig queryConfig = new QueryConfig();
queryConfig.setHighlightEnabled(false);
queryConfig.setScoreEnabled(false);
searchContext.setQueryConfig(queryConfig);
// optionally add some sorting
searchContext.setSorts(new Sort[] {...});
// get the article indexer
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(JournalArticle.class);
// get the results
Hits hits = indexer.search(searchContext);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment