Custom Property Search Exception "illegal request passed to XP-Search Aggregator API"

Hello everyone,

I’m trying to get Confluence to index my custom content properties and be able to search them. I have checked multiple pages from the docs, but haven’t made any progress.

https://developer.atlassian.com/cloud/confluence/modules/content-property-index-key-configuration/
https://developer.atlassian.com/cloud/confluence/modules/custom-content/

Custom Content Definition (atlassian-connect.json)

"customContent": [
      {
        "key": "demoResult",
        "name": {
          "value": "demo Search Result"
        },
        "apiSupport": {
          "bodyType": "raw",
          "indexing": {
            "enabled": true
          },
          "supportedContainerTypes": [
            "space"
          ]
        },
        "uiSupport": {
          "listViewComponent": {
            "moduleKey": "demoResultList"
          },
          "contentViewComponent": {
            "moduleKey": "demoResultViewer"
          },
          "icons": {
            "item": {
              "url": "/images/customers.png"
            }
          }
        }
      }
    ]

Content Properties Definition (atlassian-connect.json)

  "modules": {
    "confluenceContentProperties": [
      {
        "key": "demoResultContent",
        "name": {
          "value": "a result"
        },
        "keyConfigurations": [
          {
            "propertyKey": "demoMetadata",
            "extractions": [
              {
                "objectName": "alpha_title",
                "type": "string",
              },
              {
                "objectName": "alpha_body",
                "type": "string"
              }
            ]
          }
        ]
      },
    ]

These are the API calls that I perform manually in order:

POST base_url/wiki/api/v2/custom-content

{
  "type": "ac:my.key:demoResult",
  "status": "current",
  "spaceId": {{ _.SPACE_ID }},
  "title": "this is a test",
  "body": {
    "representation": "raw",
    "value": "test"
  }
}

returns

{
	"id": 3178497,
	"type": "ac:my.key:demoResult",
	"status": "current",
	"title": "this is a test",
	"createdAt": "2023-06-16T11:15:26.298Z",
	"authorId": "XXXXXXX",
	"spaceId": 425990,
	"body": {},
	"version": {
		"number": 1,
		"message": "",
		"minorEdit": false,
		"authorId": "XXXXXXX",
		"createdAt": "2023-06-16T11:15:26.298Z"
	},
	"_links": {
		"webui": "/display/MD/customcontent/3178497"
	}
}

POST base_url/wiki/api/v2/custom-content/Custom Content ID/properties

{
	"key": "demoMetadata",
	"value": {
		"alpha_title": "demotesttitle",
		"alpha_body": "demotestbody"
	}
}

returns

{
	"value": {
		"alpha_title": "demotesttitle",
		"alpha_body": "demotestbody"
	},
	"key": "demoMetadata",
	"id": 3080202,
	"version": {
		"number": 1,
		"message": "",
		"minorEdit": false,
		"authorId": "XXXXXXXXXXX",
		"createdAt": "2023-06-16T11:16:54.495Z"
	}
}

So far, everything looks good. Now I try to search for my newly created custom content property via CQL:
content.property[demoMetadata].alpha_title = "demotesttitle"

GET base_url/wiki/rest/api/search?cql=content.property%5BdemoMetadata%5D.alpha_title%20%3D%20%22demotesttitle%22

returns

{
	"statusCode": 400,
	"message": "com.atlassian.confluence.api.service.exceptions.SSStatusCodeException: CQL was parsed but the search manager was unable to execute the search. Error message: com.atlassian.confluence.api.service.exceptions.SSStatusCodeException: There was an illegal request passed to XP-Search Aggregator API : HTTP/1.1 400 Bad Request"
}

I have thoroughly re-read the documentation and I don’t think I’ve missed anything - what causes this error?

Dear @NicolasBrunson

honestly I never tried it this way but defining an alias for an extraction (like demoalphatitle) and then using this alias in the CQL statement always worked for me.

Good luck

Andreas

Thanks for your reply @andreas1

Funnily enough, I tried using an alias last week without success. Trying again today, it suddenly works without a problem :smile:

FWIW, I’ve adjusted the modules like this:

"extractions": [
              {
                "objectName": "alpha_title",
                "alias": "demoalphatitle",
                "type": "string"
              },
              {
                "objectName": "alpha_body",
                "type": "string"
              }
            ]

This call now works with this CQL
demoalphatitle = "demotesttitle"

GET base_url/wiki/rest/api/search?cql=demoalphatitle%20%3D%20%22demotesttitle%22