StringBuffer searchTerm = new StringBuffer();
searchTerm.append(pagelet.getModule()).append("/").append(pagelet.getIdentifier());
// Are we looking for the pagelet in a certain composer or position?
PageletURI uri = pagelet.getURI();
if (uri != null) {
if (StringUtils.isNotBlank(uri.getComposer()) && uri.getPosition() >= 0) {
field = MessageFormat.format(PAGELET_TYPE_COMPOSER_POSITION, uri.getComposer(), uri.getPosition());
and(field, searchTerm.toString(), true);
} else if (StringUtils.isNotBlank(uri.getComposer())) {
field = MessageFormat.format(PAGELET_TYPE_COMPOSER, uri.getComposer());
and(field, searchTerm.toString(), true);
} else if (uri.getPosition() >= 0) {
field = MessageFormat.format(PAGELET_TYPE_POSITION, uri.getPosition());
and(field, searchTerm.toString(), true);
} else {
field = PAGELET_TYPE;
and(field, searchTerm.toString(), true);
}