List of usage examples for com.liferay.portal.kernel.search SearchContext getNodeIds
public long[] getNodeIds()
From source file:com.liferay.portlet.wiki.util.WikiIndexer.java
License:Open Source License
@Override public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { int status = GetterUtil.getInteger(searchContext.getAttribute(Field.STATUS), WorkflowConstants.STATUS_ANY); if (status != WorkflowConstants.STATUS_ANY) { contextQuery.addRequiredTerm(Field.STATUS, status); }// w ww . ja v a 2 s. c o m long[] nodeIds = searchContext.getNodeIds(); if ((nodeIds != null) && (nodeIds.length > 0)) { BooleanQuery nodeIdsQuery = BooleanQueryFactoryUtil.create(searchContext); for (long nodeId : nodeIds) { try { WikiNodeServiceUtil.getNode(nodeId); } catch (Exception e) { continue; } nodeIdsQuery.addTerm(Field.NODE_ID, nodeId); } contextQuery.add(nodeIdsQuery, BooleanClauseOccur.MUST); } }
From source file:com.liferay.wiki.search.WikiPageIndexer.java
License:Open Source License
@Override public void postProcessContextBooleanFilter(BooleanFilter contextBooleanFilter, SearchContext searchContext) throws Exception { addStatus(contextBooleanFilter, searchContext); long[] nodeIds = searchContext.getNodeIds(); if (ArrayUtil.isNotEmpty(nodeIds)) { TermsFilter nodesIdTermsFilter = new TermsFilter(Field.NODE_ID); for (long nodeId : nodeIds) { try { _wikiNodeService.getNode(nodeId); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug("Unable to get wiki node " + nodeId, e); }/*from w w w. j a v a2s. c o m*/ continue; } nodesIdTermsFilter.addValue(String.valueOf(nodeId)); } if (!nodesIdTermsFilter.isEmpty()) { contextBooleanFilter.add(nodesIdTermsFilter, BooleanClauseOccur.MUST); } } }