CQL Query Syntax - Articles with no label
Asked by Zen Miles:

The CQL syntax appears to be a bit different in Confluence Cloud to the server version. Is there a way I can get all pages that have no labels?


Answers:
author: Jessica
body: Hello Zen!  

I hope you're well and safe!  

I'm not familiar with the Server CQL version, but there could be some differences between those products, as they are different in how they work.

For Confluence Cloud, you should be able to search for pages without a label using the following through our REST API:

```
https://yoursite.atlassian.net/wiki/rest/api/search?cql=label?NOT?IN(%22yourlabel%22,%22yourlabel2%22)?AND?type=%22page%22?AND?space=YOURSPACEKEY
```

Please make sure to change the "**yoursite** " to your site name, "**yourlabel** " and "**yourlabel2** " with the labels on your pages and "**YOURSPACEKEY**" with the space key for the space where you want to search for pages without those labels, before running it. :)

* You can find your **space key** by checking the URL, when accessing a space, should be after the /wiki/spaces, like on this example: <https://sitename.atlassian.net/wiki/spaces/>**CBC** /overview. \<\<\<  
  In this case, CBC is the space key.

<br />

I just did a quick test on a test instance by replacing the "yourlabel", "yourlabel2" for the only two labels in the space specified and it returned all the pages without a label there. :)

If you have any other labels being used in the space, you can also add them there, separating by a comma.   
If you don't, probably more pages will show up on the results and can have a label that was not specified in the "NOT IN".

For more additional information on how it works, you can check our documentation in our Developer Atlassian Community:  

* **[Confluence Cloud Developer\] Advanced searching using CQL](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/)**
* **[\[Confluence Cloud Developer\] CQL Fields](https://developer.atlassian.com/cloud/confluence/cql-fields/)**
* **[\[Confluence Cloud Developer\] REST API](https://developer.atlassian.com/cloud/confluence/rest/)**

<br />

Other than that, we don't have a way to do it through the UI, but we have a feature request suggesting it to be implemented on our Content by Label macro:

* [Allow Content By Label Macro To List Pages Without Any Labels](https://jira.atlassian.com/browse/CONFCLOUD-43823)

Hope that helps, Zen!  

Kindest Regards,  
Jessica

comments: author: CDougherty
body: Is there an easier way to do this with many labels? My space has around 100 labels with new ones added every week or two so a query like that would be unwieldy and hard to maintain.


author: Hector Barquero
body: Not sure if still needed but this works in server 7.19 and in 8.5 LTS. Tried in my cloud instance, and it seemed to work too.

**Find pages with labels**

CQL query

```
type:page AND labelText:[a TO z]
```

**The opposite, find pages with no labels**

Use this one to confirm the first CQL results. The delta should equal the total site pages.

```
type:page NOT labelText:[a TO z]
```


author: Janet Dixon
body: Hi [@Zen Miles](/t5/user/viewprofilepage/user-id/1963004) I was trying to do the same thing recently. I'm NOT a developer, so I had to dig to find something that would be quick and easy for me.

I installed the add-on CQL Search, which is free: [https://marketplace.atlassian.com/apps/1213090/cql-search?hosting=cloud\&tab=overview](https://marketplace.atlassian.com/apps/1213090/cql-search?hosting=cloud&tab=overview)

I then used the CQL Query macro, checked boxes for the items I wanted to display, one of which was a labels column, and set the query for all pages in a specified space:

space=spacekey and type=page

I now have a page with a beautiful list of all the pages in the space with their respective labels, whether they have a label or not. Now I can see all the pages that have no labels and what labels are applied to the other pages.

You could modify the query to show you only those page that have no labels.

comments: author: Zen Miles
body: Thanks [@Janet Dixon](/t5/user/viewprofilepage/user-id/4480137)! I have actually already installed CQL Query which is what I am working in. Unfortunately we have a lot of articles in our knowledgebase, so the intention was to create a section that lists only unlabeled articles. Visually scanning a list for empty cells just doesn't cut it, I'm afraid.

It seems like CQL has a serious limitation in that it doesn't have a null or empty status. I have had to resort to using NOT IN LABEL "label-a" AND NOT IN LABEL "label-b" AND NOT IN LABEL "label-c", etc.

It is extremely annoying to have to do it this way, but if it's the only way that it will work, it has to do.


author: Janet Dixon
body: [@Zen Miles](/t5/user/viewprofilepage/user-id/1963004)I was hoping to also have a list showing just the pages that have no labels. I was struggling with this as well. I'm surprised CQL doesn't have a null. I will try your method. Thanks for the tip.


Tags: cloud

confluence-cloud