REST API Relevance Query Help

I’m not very good with Relevance language yet and I have a need to query the REST API for some data. I’m looking for a relevance statement that would get the names of computers that have a custom property value set to a specific value. For example: names of computers whose (value of Custom_Property is “Something”). Can anyone help me out?

Thanks,

Ben

It’s not “safe” to search for Retrieved Properties by name. They are not guaranteed to be unique. You can repeat Property Names between Analyses. You would be better served to determine the ID of the Property you want to query on first.

From the BES Session Relevance Tester or the Presentation Debugger in the Console, evaluate the following query …

(ids of it, values of results of it) of bes properties whose (name of it = “Something”)

It will return a list of Property ID’s followed by their values …

(nnnnnnnnnn, nnnnnn, n), Some Value

1 Like

Take @TimRice’s advice and get the id of your property.
This is a 3 integer tuple (<integer>,<integer>,<integer>)

Then use this in your relevance.
For the relevance below I’ve a custom property whose id is (2299646585, 194, 1) and this property is returning the name of the operating system. So this query returns all computers with the Red Hat in the name of the operating system.

names of computers of results whose (value of it contains "Red Hat" ) of bes property whose (id of it = (2299646585, 194, 1))

Are you using the console’s presentation debugger ? Try selecting the various its in the statement and it will highlight which part of the statement the it refers to. This makes understanding the relevance a bit easier.
I also find it helps when figuring these out if you draw a sketch linking up the objects and how they link up via their properties using this as reference.

1 Like

In some cases I will get the property both by name and by site to be a little more safe, but you’re right that the specific ID is the only way to be sure. It is just less obvious what you are doing by ID in human readable terms.

In other cases I have multiple properties with the same name, but they are equivalent, so I actually want all results of all properties with the same name.

How do I do this query against a custom property created in a custom analysis? The query given seems close but fails because the property I’m looking for is not defined in bes properties or bes property.

I got it - I was trying to use the relevance debugger to evaluate the ID search, but using the REST API actually got me the answer. I can now run the query given and it’s returning the results for which I was looking. Thanks everyone!

2 Likes

To test session relevance, you need to use the Session Relevance Tester and not the Fixlet Debugger. That was your issue.

http://bigfix.me/fixlet/details/3969

You can also use the presentation debugger which is part of the console.

1 Like

Good point. The presentation debugger is great if you are on a Mac/Linux computer and can’t run the Session Relevance Tester locally. I do prefer the Session Relevance Tester in general since it has a built in guide and tabbed interface for lots of general writing of session relevance, but there are many ways to do session relevance queries.