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

This widget could not be displayed.
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
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

569 views 7 6
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