It's all about the answers!

Ask a question

Using Ram java api to search assets with attributes


idris yuce (13145) | asked Apr 26 '13, 6:45 a.m.
 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.

Accepted answer


permanent link
Rich Kulp (3.6k38) | answered Apr 26 '13, 10:18 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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

Comments
idris yuce commented Apr 26 '13, 10:46 a.m.
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 to post your answer.