留言板

Reindex all search indexes programmatically.

thumbnail
Rahul Pande,修改在11 年前。

Reindex all search indexes programmatically.

Expert 帖子: 310 加入日期: 10-7-7 最近的帖子
Hi All,

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

Thanks,
Rahul
thumbnail
vipin bardia,修改在11 年前。

RE: Reindex all search indexes programmatically.

Regular Member 帖子: 162 加入日期: 11-2-28 最近的帖子
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,修改在11 年前。

RE: Reindex all search indexes programmatically.

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
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,修改在8 年前。

RE: Reindex all search indexes programmatically.

Regular Member 帖子: 158 加入日期: 10-3-5 最近的帖子
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,修改在8 年前。

RE: Reindex all search indexes programmatically.

Regular Member 帖子: 211 加入日期: 11-10-18 最近的帖子
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);