When using the "label" attribute as follows
label=AA,BB,+CC
It appears to behave as follows.
"Neither" is not really what I wanted. I want (AA or BB) AND CC
The only way I've found to do this is to actually split the macro up into 2 macros. Although it's a bit more work, it should display as normal. For example, to achieve what you want do:
label=+AA,+CC
label=+BB,+CC,-AA
The reason for the -AA is to prevent duplicate labels.
I wanted to do the same thing and ended up creating my own hacked-up version of the macro.
Kitt - is there a chance that you share the code of your modified macro. In my opinion more advanced AND/OR "queries" are a useful feature for more advanced requirements ... Thanks for a brief reply ...
This is a little out of context, but hopefully these two files will give you a pretty good idea of what I did.
First file, "ORLabelParameter.java":
package com.pixar.confluence.plugins;
import com.atlassian.confluence.macro.query.SearchQueryInterpreter;
import com.atlassian.confluence.macro.query.SearchQueryInterpreterException;
import com.atlassian.confluence.macro.query.params.BooleanQueryFactoryParameter;
import com.atlassian.confluence.macro.MacroExecutionContext;
import com.atlassian.confluence.search.v2.SearchQuery;
import com.atlassian.confluence.search.v2.query.LabelQuery;
import com.atlassian.confluence.labels.LabelManager;
import com.atlassian.confluence.labels.LabelParser;
import com.atlassian.spring.container.ContainerManager;
/**
* Presents label parameters as {@link com.atlassian.confluence.macro.query.BooleanQueryFactory} implementations.
*
* @since 2.9
*/
public class ORLabelParameter extends BooleanQueryFactoryParameter
{
private static final String[] DEFAULT_PARAM_NAMES = { "orlabel", "orlabels" };
private LabelManager labelManager;
public ORLabelParameter()
this(null);
}
public ORLabelParameter(String defaultValue)
super(DEFAULT_PARAM_NAMES, defaultValue);
ContainerManager.autowireComponent(this);
static class Interpreter implements SearchQueryInterpreter
private boolean shouldValidate;
public void setShouldValidate(boolean shouldValidate)
this.shouldValidate = shouldValidate;
public void setLabelManager(LabelManager labelManager)
this.labelManager = labelManager;
public SearchQuery createSearchQuery(String value) throws SearchQueryInterpreterException
if (shouldValidate)
if (labelManager.getLabel(value) == null)
throw new SearchQueryInterpreterException("'" + value + "' is not an existing label");
* CONF-15398. We want to report invalid labels even if validation is suppressed using shouldValidate = false,
* as you cannot make a valid search query out of an invalid label.
* Ideally this validation should performed on the value passed to createSearchQuery() before it is invoked.
if (LabelParser.parse(value) == null)
throw new SearchQueryInterpreterException("'" + value + "' is an invalid label.");
return new LabelQuery(value);
@Override
protected SearchQueryInterpreter createSearchQueryInterpreter(MacroExecutionContext ctx)
Interpreter interpreter = new Interpreter();
interpreter.setShouldValidate(shouldValidate);
interpreter.setLabelManager(labelManager);
return interpreter;
Sure, if they're helpful, go for it!
Thanks so much for sharing your code - I'll see if we can get these enhancements contributed back to Confluence - if you don't have any objections?
Has anybody extended this to filter "pagetreeonly" vs. "global search" ?
It looks like you're new here. Sign in or register to get started.