Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,849
Community Members
 
Community Events
184
Community Groups

Adaptivist Scriptrunner CQL

Hello,

I am looking to create a user macro that allows this cql query

Skype AND (spacekey:SVCCAT or spacekey:ICS or spacekey:APPCAT)

 

But have the search term variable, so instead of typing 'Skype', and term can be used, and it will return results based on the 3 spaces I have listed.

Search Box gives a choice of 1 of the 3 spaces per search, but not all.

Can the CQL custom scriptrunner option do this?

Thoughts?

Thanks,

 

V

1 comment

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 26, 2020

This is a pretty simple way to do it by wrapping the search results macro.

Macro Name:
custom_search

Macro Title:
Custom Search

Macro Body Processing:
No macro body

Template:

## Developed by: Davin Studer
## Date created: 06/26/2020
## @noparams

<form class="aui" method="GET" action="">
    <input id="q" name="q" type="text" class="text" placeholder="" /> <button class="button">Search</button>
</form>

#set($q = $req.getParameter('q'))
#if($q && $q != "")
<p>
  <ac:structured-macro ac:name="search" ac:schema-version="1">
    <ac:parameter ac:name="maxLimit">100000</ac:parameter>
    <ac:parameter ac:name="query">($q) AND (spacekey:SVCCAT OR spacekey:ICS OR spacekey:APPCAT)</ac:parameter>
  </ac:structured-macro>
</p>
#end

oh wow!

 

Thank you Thank you Thank you!

I have never made a macro before...

Like Davin Studer likes this

Did I forget to say

 

WOW!!!!

Like Davin Studer likes this
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jul 07, 2020

Glad it helped.

It really did, super handy!

Is there a library or site of what others have done the Adaptivist ScriptRunner.  I am sure people have done crazy things!

 

Thanks again!

The search sorts by relevance, can I change that by date modified?  not sure of the syntax

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jul 13, 2020 • edited

Try this for descending ...

<ac:parameter ac:name="query">($q) AND (spacekey:SVCCAT OR spacekey:ICS OR spacekey:APPCAT) order by lastmodified desc</ac:parameter>

... or this for ascending.

<ac:parameter ac:name="query">($q) AND (spacekey:SVCCAT OR spacekey:ICS OR spacekey:APPCAT) order by lastmodified asc</ac:parameter>

https://developer.atlassian.com/server/confluence/advanced-searching-using-cql/#order-by

Hi Davin,

That makes sense, however when I added the order by, I get zero results:

 

Found 0 search result(s) for (skype) AND (spacekey:SVCCAT OR spacekey:ICS OR spacekey:APPCAT) order by lastmodified desc.

 

This is the macro content when I get zero results:

## Developed by: Davin Studer

## Date created: 06/26/2020

## @noparams

 

<form class="aui" method="GET" action="">

    <input id="q" name="q" type="text" class="text" placeholder="" /> <button class="button">Search</button>

</form>

 

#set($q = $req.getParameter('q'))

#if($q && $q != "")

<p>

  <ac:structured-macro ac:name="search" ac:schema-version="1">

    <ac:parameter ac:name="maxLimit">100000</ac:parameter>

    <ac:parameter ac:name="query">($q) AND (spacekey:SVCCAT OR spacekey:ICS OR spacekey:APPCAT) order by lastmodified desc</ac:parameter>

</ac:structured-macro>

</p>

#end

 

But this works fine

 

## Developed by: Davin Studer

## Date created: 06/26/2020

## @noparams

 

<form class="aui" method="GET" action="">

    <input id="q" name="q" type="text" class="text" placeholder="" /> <button class="button">Search</button>

</form>

 

#set($q = $req.getParameter('q'))

#if($q && $q != "")

<p>

  <ac:structured-macro ac:name="search" ac:schema-version="1">

    <ac:parameter ac:name="maxLimit">100000</ac:parameter>

   <ac:parameter ac:name="query">($q) AND (spacekey:SVCCAT OR spacekey:ICS OR spacekey:APPCAT)</ac:parameter>

</ac:structured-macro>

</p>

#end

 

Which worked:

Found 67 search result(s) for (skype) AND (spacekey:SVCCAT OR spacekey:ICS OR spacekey:APPCAT).

 

Would I have to restart the Confluence Service?  Clear caches?

 

I do appreciate you help and expertise - thank for responding!

 

V

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jul 16, 2020

Sorry, I forgot that the search results macro doesn't use CQL. It uses Lucene search syntax. Lucene, to my knowledge, does not have anything in the search syntax to specify the order.

Oh, i see!!!

 

Learned something new!  

 

Thanks again!

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events