Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to search unrecognizable DateTime format in Jira Lucene index

Tormod Haugene
Contributor
October 3, 2017

I am trying to perform a date range search directly on the Lucene index generated by Atlassian Jira. Following this guide, I hva ended up building my query in the following manner:

Capture.PNG

Which gives the Lucene query:

customfield_10106:[2010-01-10-00-00-00 TO 2020-12-10-00-00-00]

However, this search yields no results, due the format DateTime values stored in the Lucene index. 

How should I write my query to search these encoded dates?

 

Examples of indexed data:

The DateTime values are stored as shown in the following picture from Luke:

enter image description here

 

A closeup of the DateTime values stored:

enter image description here

Here is what the first result looks like from the IntelliJ debugger:

 

enter image description here

 

 

 

2 answers

1 accepted

1 vote
Answer accepted
prunge
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 4, 2017

JIRA stores dates in Lucene as the number of seconds since the Epoch (1 January 1970) in Lucene long prefix-coded format.

When viewing these values in Luke, use the 'Long (prefix-coded)' option under 'Show content as:' to show this value:

lukedate.png

Programatically, using the JIRA API, you can use LuceneUtils.dateToString() or stringToDate() to go the other way.  Or using the Lucene API, you can interpret the string value as a number of seconds by using NumericUtils.prefixCodedToLong() or longToPrefixCoded().

Try making a TermRangeQuery with lowerTerm and upperTerm filled in using LuceneUtils.dateToString(). 

Tormod Haugene
Contributor
October 6, 2017

Thank you for the thorough explanation! Using the LuceneUtils.dateToString(someDate) worked like a charm. Thanks! :-) 

0 votes
Tormod Haugene
Contributor
October 6, 2017

For future reference, here how I ended up making the range query. Thanks to Peter!

 

private Query getSampleRangeQuery() {
Date lower = new GregorianCalendar(2017, Calendar.AUGUST, 1).getTime();
Date upper = new GregorianCalendar(2017, Calendar.SEPTEMBER, 31).getTime();
return new TermRangeQuery("customfield_10106", LuceneUtils.dateToString(lower), LuceneUtils.dateToString(upper), true, true);
}

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, aafp, jira migration, marketing collaboration, end siloed work, streamline workflows, kerrie gottschalk, jira cloud admins, unified marketing, process visibility, team efficiency, cross-team collaboration

How Kerrie Gottschalk unified AAFP’s marketing team with Jira

At the American Academy of Family Physicians, siloed marketing teams faced delays and duplicate work. Kerrie Gottschalk shook things up by moving the department to Jira, streamlining processes, boosting visibility, and sparking stronger collaboration.

Read the story
AUG Leaders

Atlassian Community Events