Hi all,
I am trying to write something that will let me use the API to search for a given string throughout Confluence.
For example if I want to search for the string 'testString' I can use:
http://<localhost>:8090/rest/api/content/search?cql=type=page+and+text~"testString"&expand=body.storage
This appears to work as expected and returns all spaces/pages with 'testString' in the body of the page.
However I want to search across other Confluence sources such as:
It feels like this should be simple but try as I might I haven't been able to modify my existing query above to accommodate these other sources as the results are never found when I test it.
Has anyone done this before? Suggestions would be most welcome.
Thanks very much!
Hi Luke,
you are searching only on pages (type=page). Try leaving that parameter away:
http://<localhost>:8090/rest/api/content/search?cql=text~"testString"&expand=body.storage
This will search attachments, comments, pages & blogs. I'm pretty sure, that the page history cannot be searched.
You might want to extent the result to more than 25 hits, as it's limited to this by default.
Best
JP
Thank you Jan-Peter, thats just what I needed! I completely missed that I was still searching on pages.
As you say it doesn't seem to return 'history' values and I may have to leave that one for now but this gets me most of the way there.
Thanks again, really appreciated,
Luke
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also worth noting that you ought to make sure when you are searching multiple keywords either by using a search with cql=text or cql=title then you should make sure there is a + between each of the keywords (replacing the space) in your search string and the whole string must be enclosed by double quotes. So any code used may mean you need to add a regex to .replace the space characters in your string with a +
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.