Feature #19680
openSearch fact_values for hosts with fact1 AND fact2
Description
It is possible to fetch selected facts from Foreman for all the machines with the command below:
- curl -k -i -u 'username@company.com' "https://foreman.company.com/api/v2/fact_values?search=name%3Dvmware%3A%3Atemplate%20or%20project%3A%3Aname&per_page=10000"
vmware::template
project::name
Where the "encoded URL" provided is:
name=vmware::template or name=project::name
Question is...
The "or" clause (that we are using) works as expected, while the "and" clause surprisingly does not. Is this a known limitation? How can one query an "and" clause?¶
Updated by Dominic Cleal over 7 years ago
- Subject changed from Augeas AND clause not working? to Fact values search AND clause not working?
- Category set to Search
- Status changed from New to Need more information
Searching for a fact with name "one AND two" isn't really a valid query, there wouldn't be a fact with two names. Searching for fact "one OR two" returns facts with either name. What did you expect it to return?
Updated by Matteo Castellarin over 7 years ago
Dominic Cleal wrote:
Searching for a fact with name "one AND two" isn't really a valid query, there wouldn't be a fact with two names. Searching for fact "one OR two" returns facts with either name. What did you expect it to return?
Hi Dominic
On the fact_values endpoint I am looking for all machines having fact one having an X value and fact two having a Y value.
This works perfectly with the OR clause, but the AND clause does not accept it.
Am I doing something wrong?
Updated by Dominic Cleal over 7 years ago
- Tracker changed from Bug to Feature
- Subject changed from Fact values search AND clause not working? to Search fact_values for hosts with fact1 AND fact2
- Status changed from Need more information to New
The fact_values search doesn't permit searching for hosts with certain facts (as you're attempting), it is searching for facts only. Its search doesn't have the option to filter by hosts with multiple facts.