Is there any way at all to search facts with a ^?

We constantly need to be able to search facts on a large basis, and many of them. But there seems to be no way to search for multiple facts using ^.

eg;

facts.ssnc_cloud_subproject_id = subproject-7d9b2342-c4ca-4e48-b0cd-841ab5ab1795 or facts.ssnc_cloud_subproject_id = subproject-8f18b28d-8b87-46e9-9015-31002a7a84b0 or facts.ssnc_cloud_subproject_id = subproject-dba26e34-cd9d-482b-b0a2-9c1709eebcfa or facts.ssnc_cloud_subproject_id = subproject-f69e7502-e5c8-4caf-98f5-104c4c25489d or facts.ssnc_cloud_subproject_id = subproject-f500a2ae-44d6-4e9e-9e87-76a60db1d4c4 or facts.ssnc_cloud_subproject_id = subproject-c3044f87-be6c-4a7f-8c07-66bbdc5ce88a or facts.ssnc_cloud_subproject_id = subproject-5aa1224d-6930-488b-82ab-04602d6eadee or facts.ssnc_cloud_subproject_id = subproject-0ed04ce2-ed87-4cdd-8b02-4dbe5fab27eb or facts.ssnc_cloud_subproject_id = subproject-dcb11f45-e907-4380-86b3-8aab929c41be or facts.ssnc_cloud_subproject_id = subproject-4c6680c3-1589-4af0-aeca-3847ce406e30
 

Where as we would just like to be able to use
facts.ssnc_cloud_subproject_id ^ (a,b,c,d,e,f,g)

Where a,b,c,d,etc are the fact values.

I’ve tried so many different ways to do this, and can never find a way that works.

Foreman uses scoped_search GitHub - wvanbergen/scoped_search: Easily search you ActiveRecord models with a simple query language that converts to SQL. , if I remember correctly.

It seems you would need the OR operator.

Oh my bad Query language · wvanbergen/scoped_search Wiki · GitHub ^ is mentioned on the list of operators

The problem is that facts search uses an “external method” which is a way to accomplish more complex searches:

I don’t have full knowledge of the fact scoped_search architecture, but since fact names and fact values are stored in separate tables, I imagine this complicates things quite a bit.

2 Likes

Well, time to find out the limit of OR’s we can have. Currently we are at 390, for a single filter on a role. I feel like Im pushing Foreman further than anyone really has. Its been interesting. We are currently at 80,000 hosts, running around 1.5 million jobs a day, with grains being uploaded each time, as well as a Salt report.

2 Likes

Follow up question. Can anyone think of how to speed up fact searching for user roles?
We are trying to limit users by a certain fact. However, there are 190-350 of them. Currently it takes about 35-45 seconds to load a page because we have 80,000 hosts with some 50-150 facts per host. That obviously is not useable. So we thought - ok what if we add a smart parameter to each host and then use that as a role filter. We were hoping we could use ^ with smart params, but again we must use 1 or 2 or 3 or …. 300 or 301 - So again not ideal for searching/filtering purposes but it did reduce the page loads from 30-45 seconds per load, to around 8-10 seconds. Still not ideal, but better.

Can anyone else think of a better way to handle this, or anything else we could do to speed things up? All storage is on SSDs with 25Gb links between them.