filter_results in Chef search API


#1

I am trying to use Chef::Search::Query.search REST API to just return a few required columns instead of full node object, including the node fqdn, environment, as well as override, the query is as below:

Chef::Search::Query.new(“server url”).search(:node, ‘:’, :filter_result => {‘name’ => [‘fqdn’], ‘env’ => [‘chef_environment’], ‘override_attributes’ => [‘override’] } )

The first two attributes can be successfully retrieved, but the override is always null…
I tried to dump the node object, there are some top level attributes like “default”, “normal”, “override”, “automatic”, as well as some simple type attributes like “name”, “chef_environment”, “roles”, etc. I did some try, it seems that the filter_result supports the sub attributes within “automatic” (like fqdn, virtualization, etc) as well as the simple type top level attributes, but does not support “default”, “normal”, “override”, etc.

So the question is how I can include the override attribute in the result?

Thanks!


#2

I answered you on Stack Overflow already: http://stackoverflow.com/a/36303137/78722

Please don’t cross-post when you already have an answer.


#3

As Noah mentioned, I’m afraid you won’t be able to pull only override-level
attributes using a search. The search (and resulting data) is done against
the merged set of node attributes, meaning you will get only the final
value (and not normal vs override)