Legacy Knowledge Base
公開されました Jun. 30, 2025

検索サマリーのために必要なDocumentオブジェクトのSnippetフィールドが取得されない。

Written By

Marcos da Silva Xavier

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

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

問題

  • Liferay の公式ドキュメントに従って SearchRequestBuilderFactory を使って Search Request を作成した後、Snippet フィールドが返されません。

環境

  • DXP 7.4

解像度

Summary summary = new Summary(
document.get(prefix + titleField, titleField),
document.get(prefix + contentField, contentField));
Here, the prefix is :-
String prefix = Field.SNIPPET + StringPool.UNDERLINE;

...

SearchResponse searchResponse = searcher.search(searchRequest);

SearchHits searchHits = searchResponse.getSearchHits();

List<SearchHit> searchHitsList = searchHits.getSearchHits();

for (SearchHit hit : searchHitsList) {

Document document = hit.getDocument();

...

  • しかし、この目標を達成するためには、 SearchResponse関数 getDocuments71()を使用しなければならない。 この関数は、スニペットタイトルフィールドとスニペットコンテンツフィールドを含むドキュメントのリストを返します。 以下のコード例が参考になるだろう:

...
SearchResponse searchResponse = searcher.search(searchRequest);

List<Document> documents = searchResponse.getDocuments71();

for (Document document : documents) {
...

Did this article resolve your issue ?

Legacy Knowledge Base