How-To: Create case-insensitive user input

The wildcard() Function

The wildcard() function was added in the 1.102.0 release of LogScale. This function can be used for case-insensitive user inputs.

logscale
// ?variable creates an input box.
// Feed that directly into the wildcard() match.
// Note the =~, which is shorthand syntax that can be used
// with the "field" parameter in general in LogScale Query Language. 

user.email=~wildcard(?Username, ignoreCase=true)

The query states, "Check ?Username against user.email and make it case-insensitive."

Single Input

Note

This is a legacy method. The wildcard() function is a much easier method.

User inputs can be created by putting a ? in front of the input name, e.g. ?username would create a username input. You'll see these in dashboards, but they can also be used in queries. The inputs are case-sensitive by default. This means that an input of ADministrator would not match administrator, "Administrator, etc. The solution is to use the test() function and compare everything in lowercase. For example:

// The input is "?MyInput" and we want to match it to "UserName".
 
// First we have to assign the input to a field, otherwise it doesn't work with test().

thisInput:=?MyInput
 
// Next we compare the two strings in lower-case to see if they're equal.

test(lower(thisInput) == lower(UserName))

Because we're comparing everything in lowercase, an input of administrator would match Administrator, ADMinistrator, AdMiNiSTRATOR, etc.

Multiple Inputs

Note

This is a legacy method. The wildcard() function is a much easier method.

Let's say there are multiple inputs:

  • ?ComputerName

  • ?aid

  • ?cid

Now let's say you only need ?ComputerName to be case-insensitive. The process to accomplish that would look like this:

logscale
// Assign a different name for the variable. 
inputComputerName:=?ComputerName
// If it's a "*" then keep it, if it's blank use a "*", otherwise do a case-insensitive match. 
| case {
    test(?ComputerName == "*")
      | ComputerName = ?ComputerName ;
    test(?ComputerName == )
      | ComputerName = * ;
    test(lower(inputComputerName) == lower(ComputerName)) ;
  }
// Check the last two strings, no reason to look at case. 
| AgentIdString = ?aid AND CustomerIdString = ?cid