Can't filter query on label? How to specify label....?

Ian Cooper June 30, 2022

Im trying to do a simple search with CQL. I have confirmed I have just one confluence page with the label "dnr_pirate_keyword". However, when I specify this label as a filter, it doesn't actually filter any of the results. I only get results that match the text search piece of my CQL query, regardless of label.... lots of results...

I have tried some different syntax, but can't get the filter to work.... The text search does work, however... So it's a bit odd.

 

I can't event get this simplified query to filter down results (I get numerous pages in response).

 

cql = "space.key={} and (label = \"dnr_pirate_keyword\")".format(space)

 

-----LABEL-----

dnr_pirate_keyword

 

-------FULL CODE SNIPPET--------

import os
from atlassian import Confluence

CONFLUENCE_TOKEN = os.environ.get("CONFLUENCE_TOKEN")

confluence = Confluence(
username="ian.cooper@expel.io",
password=CONFLUENCE_TOKEN,
cloud=True)


if confluence.page_exists("DNR", "Internal product FAQs"):
print("page exists")
else:
print("page not found")

WORD = "Lacework"

def search_word(word):
"""
Get all found pages with order by created date
:param word:
:return: json answer
"""
cql = "siteSearch ~ {} order by created".format(word)
answers = confluence.cql(cql)
for answer in answers.get("results"):
print(answer)


def search_word_in_space(space, word):
"""
Get all found pages with order by created date
:param space
:param word:
:return: json answer
"""
#cql = "space.key={} and (text ~ DNRPIRATE_KEYWORD) and (text ~ {})".format(space, word)
cql = "space.key={} and (label = \"dnr_pirate_keyword\") and (text ~ {})".format(space, word)
answers = confluence.cql(cql, expand="space,body.view")
for answer in answers.get("results"):
print(answer)


if __name__ == "__main__":
search_word(word=WORD)
search_word_in_space(space="TST", word=WORD)

1 answer

1 accepted

0 votes
Answer accepted
Ian Cooper June 30, 2022

Disregard, I was conflating the two responses from my functions

Joe Bloggs June 13, 2023

Did the expansion work for you? I don't seem to be able to get the expansion as would be expected with get_page for example
answers = confluence.cql(cql, expand="space,body.view")

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events