How to find pages in Confluence with only one label?


I am trying to find pages with only one label attached to it (we have to encourage users to provide more than just  label predefined by the template). Is there a way to accomplish that? I am using the below search trying to find pages with label "how-to" and nothing besides that, but it shows me pages with no labels as well as the ones I expect.

(type: page labelText:”how-to”) AND (type: page NOT labelText:[a TO g]) AND (type: page NOT labelText:[i TO z]) AND (type: page NOT labelText:[0 TO 9])


Plus, it lists not only pages with "how-to" label - it also lists pages where "how-to" is part of the longer label name - like "kb-how-to-article"

1 answer

1 accepted

0 vote
Andy Jean Atlassian Team Dec 04, 2015

Hi Elena,

You should be able to do this through the database side. Do you know if you have access to the database (this may vary if you are using Confluence Cloud or Confluence Server). I was able to get all pages that have only 1 label using the following SQL query. Note that this is syntax for PostgreSQL but should be similar (if not exactly the same) for other database flavors. This should give you a good start in getting the details you need.


SELECT c.title as PageTitle, count(title) as NumberOfLabels from content_label cl inner join label l on cl.labelid = l.labelid inner join content c on c.contentid = cl.contentid
where  cl.labelabletype = 'CONTENT'
group by c.title
having COUNT(c.title) = 1;

Andy Jean 


Thank you! I should get a database access shortly - will try that

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

900 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you