Class LuceneUtils
java.lang.Object
com.atlassian.confluence.search.v2.lucene.LuceneUtils
Utilities for Lucene-related functionality in applications.
Some logic copied from the DateTools
class in Lucene 4.4. Done to maintain Lucene independent assumptions about how dates should be formatted for indexing.
This is required as there are many implicit baked in assumptions about date formatting around confluence, we don't want it to be changed in the future.
- Since:
- 7.16.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Specifies the time granularity. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
dateToString
(Date date) Converts a Date into a String using the Lucene index format, with a millisecond resolution.static String
dateToString
(Date date, LuceneUtils.Resolution resolution) Converts a Date to a string suitable for indexing.static String
safeEscape
(String query) static Date
Converts a String from the Lucene index format into a Date.
-
Constructor Details
-
LuceneUtils
public LuceneUtils()
-
-
Method Details
-
dateToString
Converts a Date into a String using the Lucene index format, with a millisecond resolution.- See Also:
-
dateToString
Converts a Date to a string suitable for indexing.- Parameters:
date
- the date to be convertedresolution
- the desired resolution- Returns:
- a string in format
yyyyMMddHHmmssSSS
or shorter, depending onresolution
; using GMT as timezone
-
stringToDate
Converts a String from the Lucene index format into a Date. Attempts conversion using both new and old date formats. If the String is blank or null, returns a new Date object. If the string is in the old format, this method will log a warning a limited number of times per application run to recommend that the user upgrades the index format. -
safeEscape
- Since:
- 9.1
-