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.
Accepted answer
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')
name:(asd) attribute:('abc'='qxr')
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.