Interface SearchResult
-
- All Superinterfaces:
BaseSearchResult
- All Known Implementing Classes:
AbstractSearchResult
,LuceneSearchResult
,OpenSearchSearchResult
,ProjectedSearchResult
public interface SearchResult extends BaseSearchResult
An individual search result. The SearchResult provides access to a number of attributes that are populated directly from the index without requiring an additional database hit. There should be enough information directly in the result to give a pretty detailed description of the hit. It is heavier than it's parent @see BaseSearchResult which should be used in preference when the lucene fields required to be accessed can be known by the developer in advance of the lucene query being executed.
-
-
Field Summary
Fields Modifier and Type Field Description static String
HIGHLIGHT_END
static String
HIGHLIGHT_START
Placeholders used to decorate highlighted areas of the search result
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description String
getContent()
Gets the text content of the search result.Integer
getContentVersion()
Returns the version of the content if available, ornull
if there's no version for this result.Date
getCreationDate()
String
getCreator()
Deprecated.since 5.2.ConfluenceUser
getCreatorUser()
Gets the person who created the entity represented by the search result.String
getDisplayTitle()
Gets the title of the search result appropriate for displaying to a user.default String
getDisplayTitleWithHighlights()
Gets the title of the search result appropriate for displaying to a user with matches highlighted.default Optional<String>
getExplain()
Returns query explanation if it is requested seeISearch.isExplain()
.Map<String,String>
getExtraFields()
If the retrieved documents contain additional fields that cannot be directly accessed by this interface then they can be retrieved via this method.Set<String>
getLabels(com.atlassian.user.User user)
Gets the labels on the current search result that are visible to the specified user.Date
getLastModificationDate()
Gets the last modification date of the entity represented by the search result.String
getLastModifier()
Deprecated.since 5.2.ConfluenceUser
getLastModifierUser()
Gets the last person to modify the entity represented by the search result.String
getLastUpdateDescription()
Gets some string describing the last modification to this content.String
getOwnerTitle()
If this result represents an attachment then this field will return the title of the page or blog post the attachment is attached to.String
getOwnerType()
If this result represents an attachment then this field will return the type of the container, a page or blogpost.Set<String>
getPersonalLabels()
Gets all the personal labels on the current search result.default String
getResultExcerpt()
Gets excerpt from the context of the search result.default String
getResultExcerptWithHighlights()
Gets excerpt from the context of the search result, asgetResultExcerpt()
, but in a HTML-safe manner.String
getSpaceKey()
String
getSpaceName()
String
getStatus()
Gets a string representation of the entity status represented by the search result.String
getType()
Gets a string representation of the type of the entity represented by the search result.String
getUrlPath()
Gets the URL path to the search result, relative to the site's context root.boolean
hasLabels()
boolean
isHomePage()
Checks if the search result represents the homepage of a space.-
Methods inherited from interface com.atlassian.confluence.search.v2.BaseSearchResult
getField, getFieldNames, getFieldValues, getHandle, getHandleId
-
-
-
-
Field Detail
-
HIGHLIGHT_START
static final String HIGHLIGHT_START
Placeholders used to decorate highlighted areas of the search result- See Also:
- Constant Field Values
-
HIGHLIGHT_END
static final String HIGHLIGHT_END
- See Also:
- Constant Field Values
-
-
Method Detail
-
getExtraFields
Map<String,String> getExtraFields()
If the retrieved documents contain additional fields that cannot be directly accessed by this interface then they can be retrieved via this method.The field names are abstracted from the underlying search implementation and will be centrally defined. Their values are not yet documented.
- Returns:
- Map of additional field names and their values.
-
getContent
String getContent()
Gets the text content of the search result.- Returns:
- the text content of the search result
-
getResultExcerpt
default String getResultExcerpt()
Gets excerpt from the context of the search result. Implementation could choose how to generate the result excerpts, for example, concatenated fragments of the document content where hits are found, or simply the first few words of the document.- Returns:
- excerpt of the content of the search result
-
getResultExcerptWithHighlights
default String getResultExcerptWithHighlights()
Gets excerpt from the context of the search result, asgetResultExcerpt()
, but in a HTML-safe manner. Implementations should highlight hits withHIGHLIGHT_START
andHIGHLIGHT_END
. The default implementation simply HTML-encode the result ofgetResultExcerpt()
.- Returns:
- excerpt of the content of the search result with matches highlighted
-
getType
String getType()
Gets a string representation of the type of the entity represented by the search result. If the entity is a content object, this is the value ofContentEntityObject.getType()
- Returns:
- the type of the entity represented as a string, or null if no such type can be determined
- See Also:
ContentTypeAware.getType()
-
getStatus
String getStatus()
Gets a string representation of the entity status represented by the search result. If the entity is a content object, this is the value ofContentEntityObject.getContentStatus()
- Returns:
- the status of the entity
-
isHomePage
boolean isHomePage()
Checks if the search result represents the homepage of a space.- Returns:
- true if the result represents the homepage of a space
-
getLastModificationDate
Date getLastModificationDate()
Gets the last modification date of the entity represented by the search result.- Returns:
- the last modification date of the entity
-
getLastModifier
@Deprecated String getLastModifier()
Deprecated.since 5.2. UsegetLastModifierUser()
instead
-
getLastModifierUser
ConfluenceUser getLastModifierUser()
Gets the last person to modify the entity represented by the search result.- Returns:
- the result's last modifier
- Since:
- 5.2
-
getDisplayTitle
String getDisplayTitle()
Gets the title of the search result appropriate for displaying to a user. All results should return something useful for this method.- Returns:
- the title of the search result appropriate for display on a page
- See Also:
Addressable.getDisplayTitle()
-
getDisplayTitleWithHighlights
default String getDisplayTitleWithHighlights()
Gets the title of the search result appropriate for displaying to a user with matches highlighted. All results should return something useful for this method.- Returns:
- the title of the search result appropriate for display on a page with matches highlighted
-
getUrlPath
String getUrlPath()
Gets the URL path to the search result, relative to the site's context root. All results should return something useful for this method- Returns:
- the URL path to the search result
- See Also:
Addressable.getUrlPath()
-
getLastUpdateDescription
String getLastUpdateDescription()
Gets some string describing the last modification to this content. May be null if no such string is available. For content objects, this will be the same as the "version comment"This string is user-supplied, and therefore not internationalised
- Returns:
- a string describing the last modification to the content
- See Also:
ContentEntityObject.getVersionComment()
-
getSpaceName
String getSpaceName()
- Returns:
- the name of the space that contains this search result.
-
getSpaceKey
String getSpaceKey()
- Returns:
- the key of the space that contains this search result
-
hasLabels
boolean hasLabels()
- Returns:
- true if this search result has labels, false otherwise.
-
getLabels
Set<String> getLabels(com.atlassian.user.User user)
Gets the labels on the current search result that are visible to the specified user.- Parameters:
user
- filter labels by this user- Returns:
- the labels on the current search result that are visible to the specified user.
-
getPersonalLabels
Set<String> getPersonalLabels()
Gets all the personal labels on the current search result.- Returns:
- all the personal labels on the current search result
-
getCreationDate
Date getCreationDate()
-
getCreator
@Deprecated String getCreator()
Deprecated.since 5.2. UsegetCreatorUser()
instead
-
getCreatorUser
ConfluenceUser getCreatorUser()
Gets the person who created the entity represented by the search result.- Returns:
- the result's creator
- Since:
- 5.2
-
getOwnerType
String getOwnerType()
If this result represents an attachment then this field will return the type of the container, a page or blogpost.- Returns:
- the owner type
-
getOwnerTitle
String getOwnerTitle()
If this result represents an attachment then this field will return the title of the page or blog post the attachment is attached to.- Returns:
- the owner title
-
getContentVersion
Integer getContentVersion() throws NumberFormatException
Returns the version of the content if available, ornull
if there's no version for this result.- Throws:
NumberFormatException
- if the document in the index has an unparseable version number
-
getExplain
default Optional<String> getExplain()
Returns query explanation if it is requested seeISearch.isExplain()
.
-
-