use of com.liferay.portal.kernel.search.IndexerPostProcessor in project liferay-ide by liferay.
the class AssetEntriesFacet method doGetFacetClause.
@Override
protected BooleanClause doGetFacetClause() {
SearchContext searchContext = getSearchContext();
String[] entryClassNames = searchContext.getEntryClassNames();
BooleanQuery facetQuery = BooleanQueryFactoryUtil.create(searchContext);
for (String entryClassName : entryClassNames) {
Indexer indexer = IndexerRegistryUtil.getIndexer(entryClassName);
if (indexer == null) {
continue;
}
String searchEngineId = searchContext.getSearchEngineId();
if (!searchEngineId.equals(indexer.getSearchEngineId())) {
continue;
}
try {
BooleanQuery indexerBooleanQuery = indexer.getFacetQuery(entryClassName, searchContext);
if ((indexerBooleanQuery == null) || !indexerBooleanQuery.hasClauses()) {
continue;
}
BooleanQuery entityQuery = BooleanQueryFactoryUtil.create(searchContext);
entityQuery.add(indexerBooleanQuery, BooleanClauseOccur.MUST);
indexer.postProcessContextQuery(entityQuery, searchContext);
for (IndexerPostProcessor indexerPostProcessor : indexer.getIndexerPostProcessors()) {
indexerPostProcessor.postProcessContextQuery(entityQuery, searchContext);
}
if (indexer.isStagingAware()) {
if (!searchContext.isIncludeLiveGroups() && searchContext.isIncludeStagingGroups()) {
entityQuery.addRequiredTerm(Field.STAGING_GROUP, true);
} else if (searchContext.isIncludeLiveGroups() && !searchContext.isIncludeStagingGroups()) {
entityQuery.addRequiredTerm(Field.STAGING_GROUP, false);
}
}
if (entityQuery.hasClauses()) {
facetQuery.add(entityQuery, BooleanClauseOccur.SHOULD);
}
} catch (Exception e) {
_log.error(e, e);
}
}
if (!facetQuery.hasClauses()) {
return null;
}
return BooleanClauseFactoryUtil.create(searchContext, facetQuery, BooleanClauseOccur.MUST.getName());
}
Aggregations