Hi JIRA devs
I have a problem with searching jira issue from a plugin. It's about the following code:
final JqlQueryBuilder jql = JqlQueryBuilder.newBuilder(); String projectkey = "PROJECT"; long cfkey = 10300L; String uid = "abcd1234"; Query query = where().project(projectkey).and().customField(cfkey).eq(uid).buildQuery; SearchProvider searchProvider = COMPONENT_MANAGER.getSearchProvider(); SearchResults results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter());
So this query returns an empty result set. I tried several things. Also this
Query query = where().project(projectkey).and().customField(cfkey).notEq(uid).buildQuery();
Which should actually return all the other issue in the project.
I also tried without project, just the customfield search.
And the funny thing is, this even does not work for the fields "description" and "environment" either. The user has the rights to see these issues. Selecting just the project works like a charm:
Query query = where().project(projectkey).buildQuery();
I think, something goes really wrong here. Somebody has a guess?
eq cannot be used with text fields. Use like. But be aware that it is equilent to "contains" in JQL. So the results will have everything matching to the text you passed.
Ok, it's obviously not possible to compare two strings like this.
jql.where().project(projectkey).and().customField(cfkey).eq(uid).buildQuery;
So, the way to go is to use "like" instead
jql.where().project(projectkey).and().customField(cfkey).like(uid).buildQuery;
I think this could be a quite common mistake? For me, my understanding of "like" in a not facebook but a String context is usually: "Meier" == "Meyer" => true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.