Reindex all search indexes programmatically.

thumbnail
Rahul Pande, modified 13 Years ago. Expert Posts: 310 Join Date: 7/7/10 Recent Posts
Hi All,

Does anyone know how to re-index programmatically in liferay, as we do from control panel ?

Thanks,
Rahul
thumbnail
vipin bardia, modified 13 Years ago. Regular Member Posts: 162 Join Date: 2/28/11 Recent Posts
Hi Rahul,

You can took a reference from Liferay OOTB portlet.

EditServerAction is the class which contains protected void reindex(ActionRequest actionRequest) method.
This method is used to reindexing, hope it helps....emoticon

Regards,
Vipin Bardia
vkbardia.blogspot.in
thumbnail
Hitoshi Ozawa, modified 13 Years ago. Liferay Legend Posts: 7942 Join Date: 3/24/10 Recent Posts
Take a look at the following
http://docs.liferay.com/portal/6.1/javadocs/com/liferay/portal/kernel/search/IndexerRegistryUtil.html

Example to reindex user:
Indexer indexer = IndexerRegistryUtil.getIndexer(User.class);
indexer.reindex(userId);
thumbnail
Achmed Tyrannus Albab, modified 10 Years ago. Regular Member Posts: 158 Join Date: 3/5/10 Recent Posts
Hitoshi Ozawa:
Take a look at the following
http://docs.liferay.com/portal/6.1/javadocs/com/liferay/portal/kernel/search/IndexerRegistryUtil.html

Example to reindex user:
Indexer indexer = IndexerRegistryUtil.getIndexer(User.class);
indexer.reindex(userId);


Any tips on how to reindex search ?
thumbnail
Kailash Yadav, modified 10 Years ago. Regular Member Posts: 211 Join Date: 10/18/11 Recent Posts
Achmed Tyrannus Albab:
Hitoshi Ozawa:
Take a look at the following
http://docs.liferay.com/portal/6.1/javadocs/com/liferay/portal/kernel/search/IndexerRegistryUtil.html

Example to reindex user:
Indexer indexer = IndexerRegistryUtil.getIndexer(User.class);
indexer.reindex(userId);


Any tips on how to reindex search ?

If you want to reindex all content from code, check following method : https://github.com/liferay/liferay-portal/blob/6.2.x/portal-impl/src/com/liferay/portlet/admin/action/EditServerAction.java#L369

If you want reindex a particular object do like:
Indexer indexer = IndexerRegistryUtil.getIndexer(User.class);
indexer.reindex(userId);