Auto duplicate search in JIRA

A requirement came up recently that the user should be encouraged (forced) to search for a matching existing issue before submitting a new one. This particular group spent a lot of time “deduping”, and it turns out that around 80% of their issues were closed as duplicates.

The solution outlined below, does a search for possible duplicates after the summary field loses focus. The results of the search can either be displayed below the summary, or for a more in-your-face experience, in an overlay.

At this stage the user can click the possible dupes which will open the issues in a new tab. Then they either abandon or creating a new issue, or if none of them are a match they can proceed.

imgdb.jpg

Overlays are not documented as yet but are in the latest version of the behaviours plugin. You simply build up a string of HTML to be shown in the overlay and call field.setOverlay(string). Although the setOverlay method is a member of FormField it’s not associated to any one field. Example:

imgde.jpg

To set this up I use a behaviour that contains a validator for the summary field, so, when the summary changes and the field loses focus, the search is done. If you wanted to include another field in the search, for instance the component, you would put the validator on that field, although you’d have to make it mandatory to ensure that the dupe search always happened.

Finally, this is experimental. Whether you get good results or not depends how many useful words are in the new issue summary relative to chaff words (although the common “stop” words are filtered out of the search and of the results highlighting).

Should you want to try this yourself here is the code.

https://svn.snakebite.net/onresolve/public/download/jechlin/123/AutoDupes.groovy

11 comments to Auto duplicate search in JIRA

  • Short and sweet script, but how does it work in practice?

    ~Matt

  • Hi Matt,

    Do you mean how do you set it up in practice? If so with the behaviours plugin.

    I guess though you mean how useful is it in practice… in which case I’m not really sure as this was just a (working) prototype. I was hoping someone would set it up and tell me if there is any value in it in a production environment ;-)

    jamie

  • rachael

    Ooh yeah this would be awesome! There’s an outstanding feature request in JIRA to do this or something similar – http://jira.atlassian.com/browse/JRA-1633
    If you get keen enough to package this up as a plugin, I’d be happy to beta test it for you :)

  • Markus

    Dear Jamie,

    (Jira 4.0.1)

    I wanted to use your script but always get log messages like:

    …/plugins/servlet/behaviour/dwr/exec/AjaxValidationUtils.runValidator.dwr [onresolve.jira.groovy.AjaxValidationUtils] Found class /usr/local/jira/extern/AutoDupes.groovy but could not find method getPossibleDupes
    groovy.lang.MissingPropertyException: No such property: componentManager for class: AutoDupes

    Could ypou please advise how to get the missing property?
    Thanks a lot!

    BR,
    Markus

    PS: As well example “Modify field descriptions” I could not get running.

  • There is one other (commercial) instance of this idea that I’m aware of, in addition to this approach. See http://www.suggestimate.com.

  • Markus

    Hi Matt,

    yes, I’ve seen this plugin.
    Nevertheless I would like to get the AutoDupes.groovy running.

    “Short and sweet script, but how does it work in practice?”
    Did you get this working?

    BR,
    Markus

    PS: Jamie, are you still there?? ;)

  • Hi Markus,

    Still here, bit overwhelmed with the day job at the moment.

    I don’t really get the log message you have… the property is defined in the method. What jira version are you using? I will try to reproduce.

    cheers, jamie

  • Markus

    Hello Jamie,

    thanks for answering!

    - Jira 4.0.2
    - Installed Behaviours Plugin 0.2.8
    - Added behaviour Settings:

    General Settings
    Validate Jira Requiredness Enabled (Disable)
    Use Validator Plugin Enabled (Disable)

    Guide Workflow
    Use this setting to allow the tool to show you actions and state names Changes saved automatically

    Fields
    Field: Summary
    Delete Required (Optional)
    Writable (Readonly)
    Shown (Hide)

    Validator Class: /usr/local/jira/extern/AutoDupes.groovy
    Validator Method: getPossibleDupes

    Conditions: None – Add one.

    - Mapped to issue type “Task” in a testing project
    - In AutoDupes.groovy the line “frm.Summary.setHelpText(sb.toString())” is active
    - Creating a task, typing a word in Summary, focus on next field
    => no hint shown although the word is occuring in lot of other tasks

    Maybe I just miss a basic setting?
    (CheckMinLengh works; “Modify field descriptions” not)

    Any hint appreciated!

    Thanks a lot,
    Markus

  • lfcribeiro

    Hi,

    Marcus, i had the same problem that you.
    I fix the problem changing the following, in the groovy script:

    You have to move the following line :

    ” ComponentManager componentManager = ComponentManager.getInstance()”

    Get it out of the method “getPossibleDupes” set it in the class like shown bellow.


    public class AutoDupes extends FieldBehaviours {

    // todo hrm… other languages
    def Set stopWords = StopFilter.makeStopSet(StopAnalyzer.ENGLISH_STOP_WORDS)
    ComponentManager componentManager = ComponentManager.getInstance()

    It worked for me, hope it helps.
    Thanks,
    Luís Ribeiro

  • Markus

    Hello Luís,

    THANKS a lot for your tip!

    It works great now. ;-)))

    Thanks as well to Jamie for the plugin!

    BR,
    Markus

  • rmsrini

    Will this one work on a custom field? if so how should I approach that?

    -Srini

Leave a Reply