It's all about the answers!

Ask a question

No result ?


Christophe Elek (2.9k12921) | asked Oct 24 '11, 11:00 a.m.
JAZZ DEVELOPER
Trying to get a list of error message keywords used for indexing
The following runs, but it seems I have no result....


IQueryService queryService= (IQueryService)((IClientLibraryContext)repo).getServiceInterface(IQueryService.class);
WorkItemQueryModel model= WorkItemQueryModel.ROOT;
IDataQuery query= IDataQuery.FACTORY.newInstance(model);

aQuery = (IItemQuery)query.filter(model.internalTags()._ignoreCaseLike("CRJAZ%")).distinct();
ResultIterator i = new ResultIterator(queryService, aQuery, IQueryService.EMPTY_PARAMETERS);
while (i.hasNext()) {
IItemHandle item = i.next();
if (item != null) {
print(item.toString());
}
}


What is wrong in my query ? :) should I first filter on the type ?

3 answers



permanent link
Nick Edgar (6.5k711) | answered Oct 24 '11, 5:11 p.m.
JAZZ DEVELOPER
Hi Chris,

There's some confusion between whether you're using an IItemQuery or an IDataQuery. You create a data query, but then cast to an item query when setting the filter. filter() and distinct() just return the receiver, so reassigning the query var is not needed. You should just create an item query to start with. I don't think that's the cause of the problem though, since the underlying implementation class is the same (which also explains why it's not failing with a CCE).

I think the issue is that the representation of the tags list on a work item is a specially formatted string. It separates the tags with '|', including a leading one.
e.g. if a work item had tags "foo" and "bar", then the internalTags field would be "|foo|bar|".

Try using _ignoreCaseLike("%|CRJAZ%|%").

permanent link
Christophe Elek (2.9k12921) | answered Oct 24 '11, 5:38 p.m.
JAZZ DEVELOPER
Thx Nick, seems it was it....
Now...ummm, if I understand well, I get a query of Work Item Handle...
How do I realize the 'filter' (i.e what string was match for that work item ) , do I have to realize the workItem ?

IQueryService queryService= (IQueryService)((IClientLibraryContext)repo).getServiceInterface(IQueryService.class);
WorkItemQueryModel model= WorkItemQueryModel.ROOT;
IItemQuery query= IItemQuery.FACTORY.newInstance(model);
query.filter(model.internalTags()._ignoreCaseLike("%|CRJAZ%|%")).distinct();

ResultIterator i = new ResultIterator(queryService, query, IQueryService.EMPTY_PARAMETERS);
while (i.hasNext()) {
IItemHandle item = i.next();
if (item != null) {
print(item.toString());
}
}

permanent link
Nick Edgar (6.5k711) | answered Oct 25 '11, 8:12 a.m.
JAZZ DEVELOPER
Yes, for an item query, you just get back item handles, for the items that matched.
You therefore need to read the item (using IRepositoryItemService.fetch*).

If all you're interested in doing is collecting the tags, it would be more efficient to use a data query. It may also be easier to use the IServerQueryService instead of IQueryService, as the former doesn't require paging (and the query can't get flushed from the cache while iterating like with regular queries).

Your answer


Register or to post your answer.