Search for space by title, using CQL?

I’m trying to find a space by title, using CQL, with type = 'space' and title ~ 'word'. But:

Is it possible to search for spaces with CQL? If not, is it possible to search for “all spaces starting with…” in Confluence Server?

1 Like

@aragot try an advanced search space.title ~ "cats"

That will return any spaces with “cats” in its name. It’s not a “starts with” search, but gets you closer to what you’re looking for.

Thank you for the suggestion, but I have a space named “Team” and the CQL space.title ~ "Team" doesn’t return any result through the Java API. It does return something through the Confluence search.

Found the answer! One needs to call .search() and not .searchContent():
    "type = \"space\" and title ~ \"Tea*\"",
    searchOptions, new SimplePageRequest(0, 20)

returns the space Team (and title ~ "Tea" doesn’t, so the * is actually useful).


Woohoo! Glad you figured it out (and shared the solution) :pray:

1 Like

Sorry for not marking yours as the solution, which doesn’t give you the points :wink:

haha, my solution wasn’t the solution to your problem, so it’s all good. :joy: