How to format Jira entity properties such that they are searchable via JQL

Hi,

I am looking into using Jira issue properties in my connect add-on. I am trying to store the following data into a property:

[
    {
      "id": "14471984509",
      "appId": "w5l3q6fg"
    },
    ...
]

Storing this value is not a problem at all, but I ran into issues trying to make id searchable via JQL using this property config:

{
	"jiraEntityProperties": [{
		"name": {
			"value": "Links",
			"i18n": "links"
		},
		"key": "links-property",
		"entityType": "issue",
		"keyConfigurations": [{
			"propertyKey": "links",
			"extractions": [{
					"objectName": "id",
					"type": "text"
				},
				{
					"objectName": "appId",
					"type": "text"
				}
			]
		}]
	}]
}

After re-reading the documentation a few times it seems that:

  1. the property root should be always be a JSON object (not an array as shown above)
  2. indexing array values only works if simple types string and number

Maybe I am trying to do something that is not possible in the first place. But looking at the example in this documentation made me believe this is somehow possible* (see explanation below).

Does someone know a way to:

  1. make an array at the property root searchable
  2. make object values inside an array searchable

*The example in the documentation shows how to add a task to a property called tasks (name and screenshot at the bottom suggesting you can add multiple). The task stored in the example looks as follows:

{
	content: "Test if works on Jira Cloud",
	completed: 1
}

It’s obvious that you can index this because it’s a single object at the property root. However, I do wonder what the property format looks like if there are multiple tasks (see screenshot at the bottom of the documentation => suggests you can add more tasks).

1 Like

You are so close to having it working!

the property root should be always be a JSON object (not an array as shown above)

That is correct. The array should be the last element that you reference. Otherwise, it can’t be extracted by Jira.

My recommendation would be to look at what I have done in the Hackathon for Cloud app. Here are the entity properties that I stored against an issue:

(Viewed through the Entity Property Tool)

And here is the segment of my app descriptor that references this:

      "jiraEntityProperties" : [
         {
            "name" : {
               "value" : "Hackathon Team Properties"
            },
            "keyConfigurations" : [
               {
                  "extractions" : [
                     {
                        "alias" : "hackathonTeamMembers",
                        "type" : "string",
                        "objectName" : "teamMembers"
                     },
                     {
                        "objectName" : "teamMemberCount",
                        "type" : "number",
                        "alias" : "hackathonTeamMemberCount"
                     },
                     {
                        "alias" : "isHackathonTeam",
                        "objectName" : "isTeam",
                        "type" : "string"
                     }
                  ],
                  "propertyKey" : "hackathon"
               }
            ],
            "entityType" : "issue",
            "key" : "hackathon-team-properties"
         }
      ],

If you can structure your data like that, and then refer to your content using the appropriate objectName and type in the extractions, then it should be indexed.

1 Like

Thanks @rmassaioli for the quick reply and the clarification. That did the trick :+1:

I still think the example in the documentation is a bit misleading. Looking at this screenshot (from the documentation)…

… it seems, it is possible to store more then 1 task in this property, but I believe with the property format chosen in the example this is not the case. If there is a way to add more tasks the property, the format should more look like the one given in your example.

1 Like

Hi @tbinna,

Can you please share the idea on how you formatted your data to achieve proper indexing. I too have some data stored as an array of JSON object :

[
  {
    "id": "xyz",
    "role": "dev",
    "key": "admin"
  },
  {
    "id": "xyz",
    "role": "test",
    "key": "abc"
  },
  . . .
]

Thanks,
Abhinav.

Hi @abhinav.ojha, sure, the most important point is

the property root should always be a JSON object

In your example, you’d have to nest the array in a JSON object like so:

{
  mylist: [
    {
      "id": "xyz",
      "role": "dev",
      "key": "admin"
    },
    {
      "id": "xyz",
      "role": "test",
      "key": "abc"
    },
    . . .
  ]
}

After that, you can index it by adding something like this to your descriptor:

{
  "jiraEntityProperties": [{
    "name": {
      "value": "My List",
      "i18n": "mylist"
    },
    "key": "list-property",
    "entityType": "issue",
    "keyConfigurations": [{
      "propertyKey": "com.mydomain.list.property",
      "extractions": [{
          "objectName": "mylist.id",
          "type": "text",
          "alias": "myListId"
        },
        {
          "objectName": "mylist.role",
          "type": "text",
          "alias": "myListRole"
        },
        {
          "objectName": "mylist.key",
          "type": "text",
          "alias": "myListKey"
        }
      ]
    }]
  }]
}

I did not test this myself, but I think you can index object attributes in an array like this.

Hi @tbinna,

I have tried your suggestion, it doesn’t work. I think for the reason Atlassian explained here :

wish there was a way to do this. Let me know if you got any more idea.

Thanks a lot for the quick reply and help :slight_smile:

Cheers,
Abhinav.

1 Like