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).
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)