Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Using Ram java api to search assets with attributes

 Hi all,
How can we search assets with java api by using custom attributes we created for assets?
For example lets say i have an asset asset1 and it has a an attriubte named "attribute1" rather than default attributes. 
I tried following code but it didnt work, it cant find assets.
SearchQuery query = session.createAssetQuery("name:(" + assetName+ ")  attribute1:(" + attrvalue+ ")");

Any suggestions?
thanks.

0 votes


Accepted answer

Permanent link
You would use the same query that works on the host. For example the search on the host would be:

name:(asd) attribute:('abc'='qxr')
idris yuce selected this answer as the correct answer

1 vote

Comments
Thanks for your answer richard,

I when i try attribute, asset name and asset type  in query it works,

SearchQuery query = session.createAssetQuery("name:(" + assetName+ ") type:(" + assetType + ") " + "attribute:('Service ID'='"+serviceID+"')");

but when i just use attribute with asset type it doesnt (without name) , 
SearchQuery query = session.createAssetQuery("type:(" + assetType + ") " + "attribute:('Service ID'='"+serviceID+"')");

Since that attribute is unique per asset i just want to use that attribute with asset type.

Do we have to use "name" attribute in queries?

regards.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Apr 26 '13, 6:45 a.m.

Question was seen: 4,824 times

Last updated: Apr 26 '13, 10:46 a.m.

Confirmation Cancel Confirm