Created
December 18, 2012 17:25
-
-
Save rotty3000/4329978 to your computer and use it in GitHub Desktop.
search for articles by tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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