How to change the complete String in a filter's query

Hello everybody,

I'd like to know how to change the Query String of an Query?

1 answer

1 accepted

1 vote

In the UI, edit the query in the advanced edit.

If you mean in code, create a new query and save it over the top of the old one.

Could you please be more precisely? Which methods do I need to change the filter's query. I want to put a String into Query and set it in the filter's setter method like:

String query = "project = Example And ..."

// Put that String in Query q

SearchRequest filter = ...
filter.setQuery(q);

Ok, I got the answer. That's my code:

JqlQueryParser parser = ComponentAccessor.getComponent(JqlQueryParser.class);

String queryString = ...;
Query q = null;
try
{
    q = parser.parseQuery(queryString);
}
catch (JqlParseException e)
{
   e.printStackTrace();
}

SearchRequest filter = ...;
filter.setQuery(q);

https://confluence.atlassian.com/display/JIRA040/How+to+search+in+a+plugin

Looks old, but the code is still mostly valid, and the approach is the same for 5 and 6

Ah, crossed posting, sorry!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

182 views 1 17
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you