How to find pages in Confluence with only one label?

Hi,

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 votes
Accepted answer
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 Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

118 views 3 4
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