Package org.codelibs.fess.util
Class SearchEngineUtil
java.lang.Object
org.codelibs.fess.util.SearchEngineUtil
Utility class for search engine operations and content formatting.
Provides helper methods for working with XContent builders, scrolling through search results,
and converting XContent objects to different output formats.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface for building XContent with custom logic. -
Method Summary
Modifier and TypeMethodDescriptionstatic OutputStreamgetXContentBuilderOutputStream(SearchEngineUtil.XContentBuilderCallback func, org.opensearch.core.xcontent.MediaType mediaType) Creates an OutputStream from an XContentBuilder using the provided callback function.static OutputStreamgetXContentOutputStream(org.opensearch.core.xcontent.ToXContent xContent, org.opensearch.core.xcontent.MediaType mediaType) Creates an OutputStream from a ToXContent object with the specified media type.static StringgetXContentString(org.opensearch.core.xcontent.ToXContent xContent, org.opensearch.core.xcontent.MediaType mediaType) Converts a ToXContent object to its string representation using the specified media type.static longScrolls through all documents in the specified index and applies the callback function to each hit.
-
Method Details
-
getXContentBuilderOutputStream
public static OutputStream getXContentBuilderOutputStream(SearchEngineUtil.XContentBuilderCallback func, org.opensearch.core.xcontent.MediaType mediaType) Creates an OutputStream from an XContentBuilder using the provided callback function.- Parameters:
func- the callback function to build XContentmediaType- the media type for the content builder- Returns:
- an OutputStream containing the built content, or an empty ByteArrayOutputStream if an error occurs
-
getXContentOutputStream
public static OutputStream getXContentOutputStream(org.opensearch.core.xcontent.ToXContent xContent, org.opensearch.core.xcontent.MediaType mediaType) Creates an OutputStream from a ToXContent object with the specified media type.- Parameters:
xContent- the content object to convertmediaType- the media type for the output- Returns:
- an OutputStream containing the converted content
-
scroll
Scrolls through all documents in the specified index and applies the callback function to each hit.- Parameters:
index- the name of the index to scroll throughcallback- the function to apply to each search hit, returning true to continue or false to stop- Returns:
- the number of documents processed
-
getXContentString
public static String getXContentString(org.opensearch.core.xcontent.ToXContent xContent, org.opensearch.core.xcontent.MediaType mediaType) Converts a ToXContent object to its string representation using the specified media type.- Parameters:
xContent- the content object to convertmediaType- the media type for the conversion- Returns:
- the string representation of the content
- Throws:
org.lastaflute.di.exception.IORuntimeException- if an IO error occurs during conversion
-