Custom field search

grundic
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.
December 11, 2011

Hello!

I'm developing custom field. I need to get all saved values for that field.

It could be direct SQL request or using some service - it doesn't matter.

Is there is some possibility?

Thanks in advance.

1 answer

0 votes
grundic
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.
December 12, 2011

I found, that LabelManager do it via

getSearchProvider().search(
new SearchRequest().getQuery(), 
user, 
new PrefixFieldableHitCollector(issueIndexManager.getIssueSearcher(), field, token, suggestions), 
filterQuery
);

But when I'm trying to do the same, I got empty result :(

My custom field is based on TextCFType and uses com.atlassian.jira.issue.customfields.searchers.TextSearcher. Jira allows to search via this field and return correct results. But when I'm trying to do it programmatically - it doesn't.

I tryed to use com.atlassian.query.Query as first parameter to search function but it also failed.

Here's code that I'm currently debugging:

Set<String> getSuggestions(final User user, final String field, final String query){
    
      suggestions = new TreeSet<String>();

      final Query filterQuery = new PrefixQuery(new Term(field, query));
      final JqlQueryBuilder jqlQueryBuilder = JqlQueryBuilder.newBuilder();
      jqlQueryBuilder.where().customField(10000L).like(query);
      
      try
      {
        getSearchProvider().search(
            jqlQueryBuilder.buildQuery(),
            user,
            new PrefixFieldableHitCollector(
                issueIndexManager.getIssueSearcher(),
                field,
                query,
                suggestions
            ),
            null
        );
      }
      catch (SearchException e)
      {
        throw new RuntimeException(e);
      }
    

    return suggestions;
  }

Any help is appreciated.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events