Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-21108

REST API for searching pages by labels does not return any results

      There is currently a parameter in the API that allows you to filter search results by label (see http://docs.atlassian.com/atlassian-confluence/REST/latest/#id288504) but queries that use it return an empty results list.

      eg:

      /rest/prototype/1/search/site?spaceKey=TST&type=page&label=testing
      

      will return nothing.

      Workaround for Confluence 3.5:

      User a query parameter with 'labelText' to define the label:

      /rest/prototype/1/search/site?spaceKey=TST&type=page&query=labelText:testing
      

      This workaround no longer works in Confluence 4.0+

            [CONFSERVER-21108] REST API for searching pages by labels does not return any results

            I'm trying to use this syntax but can't seen to get it to work with the "my" namespace. Here is an example of my querystring.

            http://wiki/rest/prototype/latest/search/site.json?type=page&label=my:favourite

            All I get in return is ...

            {"totalSize":0,"result":[],"group":[]}

            Currently using 5.1.2. Am I doing this wrong?

            Davin Studer added a comment - I'm trying to use this syntax but can't seen to get it to work with the "my" namespace. Here is an example of my querystring. http://wiki/rest/prototype/latest/search/site.json?type=page&label=my:favourite All I get in return is ... {"totalSize":0,"result":[],"group":[]} Currently using 5.1.2. Am I doing this wrong?

            Petch (Inactive) added a comment - - edited

            The label parameter needs to be prefixed with a namespace for the search to work as expected, typically this is the global namespace, but there are other namespaces.

            Example

            /rest/prototype/1/search/site?spaceKey=TST&type=page&label=global:testing
            

            Namespaces:

                public static final Namespace PERSONAL = new Namespace("my", VISIBILITY_OWNER);
                public static final Namespace TEAM = new Namespace("team", VISIBILITY_PUBLIC);
                public static final Namespace GLOBAL = new Namespace("global", VISIBILITY_PUBLIC);
                public static final Namespace SYSTEM = new Namespace("system", VISIBILITY_SYSTEM);
            

            labelText stopped working in 4.0 due to the escaping of the query text passed to lucene (a requirement for other searches).

            Revising rest documentation to reflect this.

            Petch (Inactive) added a comment - - edited The label parameter needs to be prefixed with a namespace for the search to work as expected, typically this is the global namespace, but there are other namespaces. Example / rest /prototype/1/search/site?spaceKey=TST&type=page&label=global:testing Namespaces: public static final Namespace PERSONAL = new Namespace( "my" , VISIBILITY_OWNER); public static final Namespace TEAM = new Namespace( "team" , VISIBILITY_PUBLIC); public static final Namespace GLOBAL = new Namespace( "global" , VISIBILITY_PUBLIC); public static final Namespace SYSTEM = new Namespace( "system" , VISIBILITY_SYSTEM); labelText stopped working in 4.0 due to the escaping of the query text passed to lucene (a requirement for other searches). Revising rest documentation to reflect this.

            Just tested in two version of Confluence, and it looks like the workaround is broken in Confluence 4.0+:

            Confluence 3.5.17

            http://localhost:43517/rest/prototype/1/search?query=labelText:axis
            

            Results XML:

            <results>
            <result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="contentEntity" type="page" id="917506">
            <link rel="alternate" type="text/html" href="http://localhost:8080/display/test/Recently+Updated"/>
            <link rel="alternate" type="application/pdf" href="http://localhost:8080/spaces/flyingpdf/pdfpageexport.action?pageId=917506"/>
            <link rel="self" href="http://localhost:8080/rest/prototype/1/content/917506"/>
            <title>Recently Updated</title>
            <wikiLink>[test:Recently Updated]</wikiLink>
            <lastModifiedDate date="2013-01-16T17:41:10-0800" friendly="Jan 16, 2013"/>
            <createdDate date="2013-01-16T17:41:10-0800" friendly="Jan 16, 2013"/>
            <space type="space" title="Test" name="Test" key="test">
            <link rel="self" href="http://localhost:8080/rest/prototype/1/space/test"/>
            </space>
            </result>
            <result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="spaceEntity" type="space" title="Test" name="Test" key="test">
            <link rel="self" href="http://localhost:8080/rest/prototype/1/space/test"/>
            <link rel="alternate" type="text/html" href="http://localhost:8080/display/test"/>
            <lastModifiedDate date="2012-12-10T14:12:33-0800" friendly="Dec 10, 2012"/>
            <createdDate date="2012-12-10T14:12:33-0800" friendly="Dec 10, 2012"/>
            <wikiLink>[test:]</wikiLink>
            </result>
            <totalSize>2</totalSize>
            </results>
            

            Confluence 4.0

            http://localhost:4400/rest/prototype/1/search?query=labelText:axis
            

            Results XML
            <results>
            <totalSize>0</totalSize>
            </results>

            Both instance have a space with key 'test' and their Home page had the 'axis' label added to it.

            Adam Laskowski (Inactive) added a comment - Just tested in two version of Confluence, and it looks like the workaround is broken in Confluence 4.0+: Confluence 3.5.17 http: //localhost:43517/ rest /prototype/1/search?query=labelText:axis Results XML: <results> <result xmlns:xsi= "http: //www.w3.org/2001/XMLSchema-instance" xsi:type= "contentEntity" type= "page" id= "917506" > <link rel= "alternate" type= "text/html" href= "http: //localhost:8080/display/test/Recently+Updated" /> <link rel= "alternate" type= "application/pdf" href= "http: //localhost:8080/spaces/flyingpdf/pdfpageexport.action?pageId=917506" /> <link rel= "self" href= "http: //localhost:8080/ rest /prototype/1/content/917506" /> <title>Recently Updated</title> <wikiLink>[test:Recently Updated]</wikiLink> <lastModifiedDate date= "2013-01-16T17:41:10-0800" friendly= "Jan 16, 2013" /> <createdDate date= "2013-01-16T17:41:10-0800" friendly= "Jan 16, 2013" /> <space type= "space" title= "Test" name= "Test" key= "test" > <link rel= "self" href= "http: //localhost:8080/ rest /prototype/1/space/test" /> </space> </result> <result xmlns:xsi= "http: //www.w3.org/2001/XMLSchema-instance" xsi:type= "spaceEntity" type= "space" title= "Test" name= "Test" key= "test" > <link rel= "self" href= "http: //localhost:8080/ rest /prototype/1/space/test" /> <link rel= "alternate" type= "text/html" href= "http: //localhost:8080/display/test" /> <lastModifiedDate date= "2012-12-10T14:12:33-0800" friendly= "Dec 10, 2012" /> <createdDate date= "2012-12-10T14:12:33-0800" friendly= "Dec 10, 2012" /> <wikiLink>[test:]</wikiLink> </result> <totalSize>2</totalSize> </results> Confluence 4.0 http: //localhost:4400/ rest /prototype/1/search?query=labelText:axis Results XML <results> <totalSize>0</totalSize> </results> Both instance have a space with key 'test' and their Home page had the 'axis' label added to it.

            For me, the workaround doesn't work at all, It just does he same returning zero results as the original. I'm running confluence 4.2.7, any help would be appreciated.

            Matt

            Matt Albone added a comment - For me, the workaround doesn't work at all, It just does he same returning zero results as the original. I'm running confluence 4.2.7, any help would be appreciated. Matt

            FWIW, I was just looking for an easy way to grep pages on our wiki by label. The first thing I tried was:

            /rest/prototype/1/search/site?type=page&label=foo

            I expected it to return all pages with the "foo" label, but got an empty result list instead. Fortunately, I found this ticket with a workaround. Thanks, Al!

            Burke Mamlin added a comment - FWIW, I was just looking for an easy way to grep pages on our wiki by label. The first thing I tried was: / rest /prototype/1/search/site?type=page&label=foo I expected it to return all pages with the "foo" label, but got an empty result list instead. Fortunately, I found this ticket with a workaround. Thanks, Al!

            Hi Sherif,

            No we aren't using the SOAP API.. We were looking into what content Confluence makes available via the REST api and noticed it has no 'hooks' for labels and space information . What we were hoping to do is access wiki labels and space information so that we can bring the wiki links we have into other web sites that exist outside of confluence. Basically, in effect, via REST, making Confluence serve out the content we need from it as a service. Is this making sense?

            Alfonse Pinto added a comment - Hi Sherif, No we aren't using the SOAP API.. We were looking into what content Confluence makes available via the REST api and noticed it has no 'hooks' for labels and space information . What we were hoping to do is access wiki labels and space information so that we can bring the wiki links we have into other web sites that exist outside of confluence. Basically, in effect, via REST, making Confluence serve out the content we need from it as a service. Is this making sense?

            Hi Al,
            It would be great to hear why this is important to you? Do you use the SOAP API? Why is REST API end points for Labels and Space labels helpful for you? What are you trying to do?
            Sherif

            Sherif Mansour added a comment - Hi Al, It would be great to hear why this is important to you? Do you use the SOAP API? Why is REST API end points for Labels and Space labels helpful for you? What are you trying to do? Sherif

              cpetchell Petch (Inactive)
              5bddf9d55ec5 Alfonse Pinto
              Affected customers:
              6 This affects my team
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: