Skip to content

Instantly share code, notes, and snippets.

Created June 22, 2017 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/c3f98deedbae285e293b2fdddb28909e to your computer and use it in GitHub Desktop.
Save anonymous/c3f98deedbae285e293b2fdddb28909e to your computer and use it in GitHub Desktop.
Groovy Liferay re-index specific User
import com.liferay.portal.kernel.search.IndexerRegistryUtil;
import com.liferay.portal.kernel.search.Indexer
import com.liferay.portal.model.User
import com.liferay.portal.util.*;
import com.liferay.portal.service.*
import com.liferay.portal.service.ServiceContext;
try {
long companyId = PortalUtil.getDefaultCompanyId();
User user = UserLocalServiceUtil.getUserByScreenName(companyId, "sasupport" );
out.println("User:"+user);
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
indexer.reindex(user);
out.println("User reindexed");
}catch (e) {
out.println("Error = " + e.getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment