I would like to ask, how can I search web-content of my site for a specific group-id.
Now I have a method which searches correctly by keyword
in all of the web-content but doesn't search for a specific group-id.
Any ideas?
HttpServletRequest httpReq = FacesService.getHttpServletRequest();
//PortalUtil.getHttpServletRequest((PortletRequest) facesContext.getExternalContext().getRequest() );
//(PortletRequest) facesContext.getExternalContext().getRequest()
SearchContext searchContext = SearchContextFactory.getInstance(httpReq );
searchContext.setKeywords(query);
searchContext.setEnd(2000);
searchContext.setStart(0);
String[] entryCalssName = {JournalArticle.class.getName()};
searchContext.setEntryClassNames(entryCalssName);
searchContext.setAttribute(Field.GROUP_ID, 14603);
Facet assetEntriesFacet = new AssetEntriesFacet(searchContext);
assetEntriesFacet.setStatic(true);
searchContext.addFacet(assetEntriesFacet);
Facet scopeFacet = new ScopeFacet(searchContext);
scopeFacet.setStatic(true);
searchContext.addFacet(scopeFacet);
Indexer indexer = FacetedSearcher.getInstance();
Hits hits = indexer.search(searchContext);
List<JournalArticle> searchResults = new ArrayList<JournalArticle>();
documents = hits.toList();
if (documents != null && !documents.isEmpty()) {
for(Document doc : documents) {
Long classPK = Long.parseLong(doc.get(Field.ENTRY_CLASS_PK));
AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(JournalArticle.class.getName(), classPK);
JournalArticle article = JournalArticleLocalServiceUtil.getLatestArticle(assetEntry.getClassPK());
System.out.println(article.getGroupId());
// if(article.getGroupId() == groupId){//I would like to get rid of this
searchResults.add(article);
// }
}
}