Documentation for Confluence 5.4.
Documentation for Confluence OnDemand and earlier versions of Confluence is available too.

Skip to end of metadata
Go to start of metadata

The Search Results macro searches your Confluence site based on search terms specified in the macro parameters, and displays the results on the wiki page.

Using the Search Results macro

To add the Search Results macro to a page:

  1. In the Confluence editor, choose Insert > Other Macros.
  2. Find and select the required macro.

Speeding up macro entry with autocomplete: Type { and the beginning of the macro name, to see a list of suggested macros. Details are in Using Autocomplete.

To edit an existing macro: Click the macro placeholder and choose Edit. A macro dialog window will open, where you can edit the parameters of the macro.

Parameters

Parameters are options that you can set to control the content or format of the macro output. Where the parameter name used in Confluence storage format or wikimarkup is different to the label used in the macro browser, it will be listed below in brackets (example).

Parameter

Default

Description

Search Terms
(query

none

The search terms which this macro will use to generate its results.

You can refine your search query by using operators such as 'AND' and 'OR'. For example: my_query1 AND my_query2

For more information, take a look at the documentation on the Confluence search syntax.

Maximum Number of Results
(maxLimit

10

Set a limit to the number of search results displayed.

Restrict to this Space Key

all

Start typing the space name to find the space, or specify the key of the space you want to search in. Note that the key is case sensitive.

Content Type
(type

all

Specify the content type. The content types are: page, comment, blogpost, attachment, userinfo (the content of user profiles only) and spacedesc (the content of space descriptions only).

Last Modified
(lastModified

all

Specify a period of time in weeks, days, hours and/or minutes, to see the content modified within that time frame.

These are the values you can use:
  • w = weeks
  • d = days
  • h = hours
  • m = minutes

For example:

  • 2h 35m
  • 3d 30m

Notes:

  • If no time category is specified, Confluence assumes minutes.
  • If you specify more than one time period (for example, weeks and days), you must separate the periods with a space. You can put them in any order.
  • The time categories are not case sensitive. For example, '4d' is the same as '4D'.

Restrict to this Username
(contributor

all

Specify the username of a Confluence user, to show only content created or updated by that user.

Notes

Permissions: When a user views the page containing the Search Results macro, the search results will show only pages and other content types for which the user has 'View' permission.

 

Code examples

The following examples are provided for advanced users who want to inspect or edit the underlying markup for a Confluence page. 

Macro name: search

Macro body: None.

Storage format example

Wiki markup example

32 Comments

  1. Anonymous

    I am using the search macro

    {search:query=|lastModified=5d|maxLimit=6|type=page|spacekey=MYSITE}
    

    and it returns fairly recently created and modified pages, but not the latest. Any clues why this could be happening?

    1. I am using the search macro

      {search:query=|lastModified=5d|maxLimit=6|type=page|spacekey=MYSITE}
      

      and it returns fairly recently created and modified pages, but not the latest. (question) Any clues why this could be happening?

      1. Hi,

        My hunch is the indexing job has not kicked in yet. Please try to manually run the indexing and see if it helps. You may want to temporarily remove the "maxLimit=6" to see a complete list.

        Cheers,
        Azwandi

        1. I'll ask our Wiki Admin about indexing frequency. I'll also try removing the maxLimit. (BTW, what is the default maxLimit ?

          The only way I get recent hits is if I use "lastModified=1d". Any other (larger) setting gives me hits that are +/- close to present , but not accurate.  Tried with 5d, 7d, 1w, but it did not work perfect*.*

          Just been trying different settings.

          ^{search:query= |spacekey=mySite|type=page|lastModified=1d}^
          

          That is the only that seemed to work. "1d". And it does yield reults for today. Any other, looks like it's setting a time gap.

          (question) I'm wondering if there are any Confluence settings that might be causing this...?

          Appreciate your reply. Thanks for the help (smile)

          1. By default, the maxLimit will be set to no value, hence it will just list down all the results. I am not aware of any settings that may cause this issue, however, I would suggest you to raise a support request at http://support.atlassian.com in case the problem gets more complicated.

            Cheers,
            Azwandi

  2. Is there a way to hide the "Found x search result(s) for xxxx" title while running a search? I'm using it to show all of the pages edited or created by a specific user but since its an empty query it shows a very unaesthetic '$query" in the title. Thanks.

    1. Hi,

      You need to customize ConfluenceActionSupport.properties which is located in confluence-x.x.x.jar file in <Confluence install>/confluence/WEB-INF/lib. There is the following text inside, which is used to display the mentioned text:

      people.search.results.found=<p>Found <b>{0}</b> result(s) for query <em>{1}</em>
      

      You may want to erase it and leave it blank and then recreate a jar file.

      Cheers,

  3. How do I produce a list of results sorted by modified date, starting with the most recent?

    1. Hi Guillermo,
      I believe the search box at the top right of your Confluence might help you to do this. This search box provide items which are ordered with the most recently modified first. Refer here for further information. Hence if you want this feature to be available in macro form, the Advance Search Plugin will be helpful. Refer the attached link for more information about Advanced Search Plugin and how to use it.

      Hope that helps

      Cheers
      Komathi

  4. Anonymous

    hey to  all,

    i want to display the current time using wiki markup.

    Plz anybody can help me in this regard

    thank you

    tabi

    1. Hi Tabi,

      I found a new feature request in JIRA:

      Feel free to add your comment on the ticket, vote for it and add yourself as watcher for future updates.
      Also, please bear in mind the following document on how we schedule features for inclusion in our products: Implementation of New Features and Improvements.

      However, you might want to try embed external content to Confluence page using the html macro or using user macro example:

      Get the HTML markup then paste it to the user macro, now in the Confluence page
      insert the User macro.

      Hope that helps.
      Best rgds,
      Zed

  5. Hi, I'm cleaning up the users and groups... and it warns me that if I delete a certain group or user, those previously restricted will be visible to all. So I want to search for these pages that have been restricted before deleting the user or the group.

    On the search above, the user is only based on contributor and not on restrictions. Any clue on how I can do the search for restrictions? e.g. search for all pages where restriction include usergroup1.

    Thanks

    1. Hi Bailey,

      I believe that you can query the Confluence database directly to get this information:

      You can substitute cp.username with cp.groupname to look up restrictions based on groups. This query will return a list of contentid, which in turn can be accessed in Confluence via the following link:

      Hope that helps!

      Cheers,
      Azwandi

  6. Just as page labels can be used to search only pages with a set of labels, is it possible to search in spaces that have a specific spaceLabel applied to them? We have spaces categorized using spaceLabels, and would like to provide enhanced Search to the communities that use spaces of those categories so that they get search-results from the domain of spaces that are of interest to them. Please advise if it is possible out-of-the-box? Or any suggestions as to how this can be accomplished.

    Thanks

    1. Sorry if this comes in a little late, Subhash. I am afraid that it is not possible to accomplish this with the out-of-the-box features. You might be interested in CONF-7227 or you can raise a new feature request in case that does not suit your requirements. Hope that helps.

  7. Anonymous

    I am trying to find a way to use this macro

    Found 10 search result(s) for my_query.

    Page: Search Macro (Confluence 1.4 User Guide)
    Search Macro does an inline site search and displays the results in the page. Search Macro What you need to type What you will get Optional Parameters Set a limit to the number of search results displayed Specify the key of the space you ...
    Nov 24, 2005
    Page: Search Macro (Confluence 2.10)
    Search macro searches your Confluence site based on search terms specified in the macro code, and displays the results on the wiki page. Usage In the example below, we assume that you want to search for all pages and other content types which ...
    Feb 20, 2009
    Labels: macro, search
    Page: Search Macro (Confluence 2.9)
    Search macro searches your Confluence site based on search terms specified in the macro code, and displays the results on the wiki page. Usage In the example below, we assume that you want to search for all pages and other content types which ...
    Aug 07, 2008
    Page: Search Macro (Confluence 2.7)
    You need to edit in 'Wiki Markup' mode to include macros in your page. The Search Macro does an inline site search and displays the results in the page. Search Macro What you need to type What you will get Optional Parameters ...
    Jun 18, 2007
    Page: Search Macro (Confluence 2.5)
    You need to edit in 'Wiki Markup' mode to include macros in your page. The Search Macro does an inline site search and displays the results in the page. Search Macro What you need to type What you will get Optional Parameters ...
    Sep 05, 2007
    Page: Search Macro (Confluence 2.0)
    You need to edit in 'Wiki Markup' mode to include macros in your page. The Search Macro does an inline site search and displays the results in the page. Search Macro What you need to type What you will get Optional Parameters ...
    Jun 25, 2007
    Page: Search Macro (Confluence 2.5.6)
    You need to edit in 'Wiki Markup' mode to include macros in your page. The Search Macro does an inline site search and displays the results in the page. Search Macro What you need to type What you will get Optional Parameters ...
    Jun 18, 2007
    Page: Search Macro (Confluence 2.6)
    You need to edit in 'Wiki Markup' mode to include macros in your page. The Search Macro does an inline site search and displays the results in the page. Search Macro What you need to type What you will get Optional Parameters ...
    Jun 18, 2007
    Page: Search Macro (Confluence 3.0)
    Search macro searches your Confluence site based on search terms specified in the macro code, and displays the results on the wiki page. On this page: Usage with the Macro Browser To insert the search macro into a page using the Macro Browser, Once you've found ...
    Jun 25, 2010
    Labels: macro, search
    Page: Search Macro (Confluence 3.1)
    Search macro searches your Confluence site based on search terms specified in the macro code, and displays the results on the wiki page. On this page: Usage with the Macro Browser To insert the search macro into a page using the Macro Browser, Once you've found ...
    Jun 27, 2010
    Labels: macro, search
    , but would like to use it to generate dynamic content, based on the page title.

    For example, use

    Found 10 search result(s) for "title of this page".

    PNG File confluence-documentation-title-page.png (Atlassian OnDemand Documentation > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 20, 2013 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 3.2 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 3.3 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 3.1 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 3.0 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 2.10 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 3.4 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 4.2 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 4.0 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    PNG File confluence-documentation-title-page.png (Confluence 4.3 > Space Attachments Directory)
    ... Confluence Documentation Title Page for PDF Exports
    Image - 7 kB - May 22, 2009 - Download - Attachments
    , so I can find pages that  have this text. I can not find in the documentation, or maybe I am not looking where I should.

    Thanks

    1. Hi,

      Sorry for the late reply. One way that I can think of is to create a user macro:

      Macro name: myquery
      Macro has a body: false
      Output: Macro generates wiki markup
      Template:

      You should be able to call the macro from within a Confluence page, as simple as:

      Hope that helps!

      Cheers,
      Azwandi

      1. Azwandi, would there be a parameter I could use instead of $title to create a link to a search, i.e.:

        Click to search Confluence for Foo.

        and have the search term Foo entered into the search macro?

        Thanks,

        Ian

  8. Hi all,

    i would like to have a search box in my web page.if i enter a regular expression eg.[sz] it has

    to search in my space what are the page titles contained sz. eg: serialize is the page title in

    my space. plz suggest me how to create a user macro for that. asap

  9. Anonymous

    Hi is it possible to get only the number captured from the search results?. We are using this macro to find out the contribution from the community members. It would be helpful, if we we could get only the number based on search queried using specific contributor.

    Thanks in advance

    1. Hi,

      You can workaround it by hiding the search results using CSS within HTML Macro, for example:

      {html}
      <style>
      .result
      {display:none;}
      </style>
      {html}
      
      {search:query=abc|contributor=username}
      

      Alternatively, the best way to generate the information you required is by using Contributors Plugin. Please refer to the following pages for more details:

      Hope that helps (smile)

      Cheers,
      Husein

      1. Anonymous

        Hi, Thank you very much. It worked. I want to display only the number, hence to remove the wording "Display    Results ", as we are not the Confluence admins, we will not be able to remove these from the server, the only option is that we need to remove using the different style configured for this purpose.

        Reference to your links to Contributors plug-in, these are disabled due to the performance issues, and that is the reason we have explored if this could work.

        Thanks once again

  10. Anonymous

    Hi guys,

    I managed to make the search macro search for the site title using Azwandi's workaround above, thanks for that!

    I wonder if it is possible to create a search macro which performs an OR-search using the site's tags.

    For example:

    tag1 tag2 tag3

    Found 0 search result(s).

    Thanks!

    1. Hi, I presume that you are referring to labels. In that case, you can use this markup:

      {search:query=labelText:tag1 OR labelText:tag2 OR labelText:tag3}

      For more information, take a look at Confluence Search Syntax and Confluence Search Fields.

      1. Anonymous

        Hi Azwandi,

        thanks for the quick response.

        Unfortunately, this is not was I was looking for ;)

        Maybe my intention becomes clearer if I give you an example:

        Lets say an article about a car has these labels:

        Audi, Car and Engine

        Then I want the search macro to do a seach like: Audi OR Car OR Engine

        The result should be that I see a list of related articles, like "these articles could be interesting as well".

        You understand what my intention is? ;)

        Cheers,

        Dennis

        1. Anonymous

          Is this not possible? Would be of great adavnce for our company

        2. Anonymous

          Is this not possible? Would be of great adavnce for our company

        3. Anonymous

          Is this not possible? Would be of great adavnce for our company

  11. Hi,

    This info may already be posted somewhere, but is there a way to customize the search macro so the wear "Search" appears within the search field like in the upper right corner of this page?

    Thanks,

    Anna

    1. Hi Anna,

      Sorry if I misinterpreted your question, but it seems to me that you would like a search box on top of the search results? If that is the case, you could specify another macro such as the Pagetree Search Macro or Livesearch Macro.

      Cheers,
      Azwandi

  12. Anonymous

    Hi, I want to know if the search result can retrieve the whole comment box with the actions, like Edit, Reply, and Comment. Also, how do you get the profile picture to display to know the username of the comment? 

  13. How can you customize the format of the results, particularly from userinfo content?  For instance, to show a person's picture, rather than the generic "profile" icon.