legacy-knowledge-base
公開されました Jul. 2, 2025

スクリプトによる再インデックス

written-by

József Géczi

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • 開発者として、UIから実行するのではなく、スクリプトを使用してポータルで再インデックスをトリガーしたいと思います。 これは例えば、スケジューリング可能な再インデックスに有用な可能性があります。

環境

  • Liferay DXP 7.1
  • Liferay DXP 7.2
  • Liferay DXP 7.3

解決

スクリプト、CLI/シェル コマンド、または API 呼び出しを介してインデックス再作成をトリガーすることに関する「公式推奨事項」は存在しません。

ただし、以下のサンプルGroovyスクリプトは、そのような期待に近づけるために使用することができます(スクリプトは、メニューのサーバ管理 -> スクリプトで実行できます):

def companyId = com.liferay.portal.kernel.util.PortalUtil.getCompanyId(actionRequest);def userId = java.lang.Long.parseLong(userInfo.get("liferay.user.id"));
com.liferay.portal.kernel.search.IndexWriterHelperUtil.reindex(userId, "reindex", [companyId] as long[], null);

上記のスクリプトは、スクリプトが実行された場所から、ある特定のCompanyのインデックスを再作成します。 しかし、 PortalUtil.getCompanyId() を使えば、必要なすべての companyIdに対して再インデックスをトリガーすることが可能なはずです。

再インデックス中に、Liferayのログに以下のような警告が表示される可能性があることを予期してください:

org.apache.tika.config.InitializableProblemHandler$3 handleInitializableProblem
WARNING: TIFFImageWriter not loaded. tiff files will not be processed
See https://pdfbox.apache.org/2.0/dependencies.html#jai-image-io
for optional dependencies.
J2KImageReader not loaded. JPEG2000 files will not be processed.
See https://pdfbox.apache.org/2.0/dependencies.html#jai-image-io
for optional dependencies.

org.apache.tika.config.InitializableProblemHandler$3 handleInitializableProblem
WARNING: org.xerial's sqlite-jdbc is not loaded.
Please provide the jar on your classpath to parse sqlite files.
See tika-parsers/pom.xml for the correct version.

再インデックスは、ハイライトされたタイプのファイルには効果がない(そのような動作は意図されている)ことを理解した上で、これらの警告を安全に無視することができます。

追加情報

  • 注意:このようなカスタムスクリプトは、十分なテストを行った後、ご自身の判断で本番にのみ適用することができます。
did-this-article-resolve-your-issue

legacy-knowledge-base