how to force indexing over calculated number field

Georges Moubarak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2016

Hi,

I have created a Calculated number field that calculates the number of working days since the issue is last updated. The field works well but the issue is that to be able to search that field, the issues must be indexed. Normally an issue is indexed at any update over it but in my case there will be no updates. So the field won't be searchable until you perform a manual re-indexing. Is there is a way to enforce the indexing of an issue when the field is calculated? Or there is a better way to search for issues that are not updated since more than 3 working days?

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 5, 2016

>but in my case there will be no updates.

That stands out to me as being wrong.  Why will there be no updates?  What is your field calculating?  If there's no updates to the issue, then it suggests you're calculating from dynamic or non-JIRA data, which means a scripted field is not the right approach.

Georges Moubarak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2016

Hi @Nic Brough [Adaptavist],

The field is calculating the number of working days since the last updated date.

When I search for this field in JQL(e.g. "field">3) it doesn't return a value but the value is there. After I perform an indexing the issues are retrieved through the JQL query.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 5, 2016

Ok, that makes sense.

The problem here is that you've defined a data item that is not static.  Think of it this way - when should the field be calculated?  The underlying information of "time since x" is variable - it's a different answer now from what it was when I first answered, when I got up and read the response, when I started typing.  JIRA stores time data in milliseconds, so that's the highest granularity you could use and means you could really be asking to index the field 1000 times a second.  In real life, you've probably got a granularity of an hour or a day or something more sane, but the problem is the same - you're going to need to calculate and re-index your entire system on every "grain" of time.

A better answer would be "calculate on display".  Take a fixed time from the issue (last updated date) and make the system displaying it show "elapsed time".  I don't know how to do it myself, but some javascript for "show me time elapsed since updated date" that runs on issue view solves the display problem (of all my Atlassian related skills, javascript is the weakest).  For searching, use the relative times and the raw updated date.

Georges Moubarak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2016

@Nic Brough [Adaptavist], my problem is not with the display. The field is displayed correctly whenever I check the request but my problem is with being able to query it. Before the indexing the value is considered as null but you can see the value of the field which is correct.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 5, 2016

I think you've missed the point.  Your design is broken because your search is for a value that changes 1,000 times a second.  Storing "elapsed time" in the scripted field is inaccurate even before the write cycle is finished.

What you need to do is re-phrase the search in useful terms.  For example, instead of "time elapsed since update is over seven days", use "updated more than seven days ago".  When you rewrite the question with the dynamic value being "now" instead of "elapsed time", the problem goes away.

Georges Moubarak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2016

@Nic Brough [Adaptavist], my field gets the difference between the "update" date and "now" and tweaks it to remove the weekends.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 5, 2016

Ok, there's an additional calculation to be done, that's fine.

But, again, it's still changing 1,000 times a second during the working day.  You still need to change your approach from "elapsed" to "time since"

Suggest an answer

Log in or Sign up to answer