FAST Search: Finding and filtering null text values
In customizing our various elements of our FAST Search center, I've often run into the need to search for and/or remove particular search results that have a null value in a particular text field. For instance, I have built a Staff Directory using the People Results Source; however, it also displays various service, consultant accounts, and unfortunately, the AD side in our org isn't always up to date in terms of disabling accounts or standardizing particular fields except for what comes through our search as the "Office" field. So basically, I first wanted to query the existing staff directory to see what results came up that did not have an entry in the Office field. Because search won't return a null value and wildcards searches are limited somewhat to "Begins with", I used the Fast Query Language to filter for any results that did not begin with a letter of the alphabet, like so:
(-Office:a* AND -Office:b* AND -Office:c* AND -Office:d* AND -Office:e* AND -Office:f* AND -Office:g* AND -Office:h* AND -Office:i* AND -Office:j* AND -Office:k* AND -Office:l* AND -Office:m* AND -Office:n* AND -Office:o* AND -Office:p* AND -Office:q* AND -Office:r* AND -Office:s* AND -Office:t* AND -Office:u* AND -Office:v* AND -Office:w* AND -Office:x* AND -Office:y* AND -Office:z*)
As a "-" sign before the property in question translates to a "NOT", so essentially we are saying the field can't begin with any letter of the alphabet.
After I investigated the fields, I wanted to change the query in the Core Result web part on my Staff Directory page to ONLY show results that have a begin with a letter of the alphabet, so I changed the query to:
(Office:a* OR Office:b* OR Office:c* OR Office:d* OR Office:e* OR Office:f* OR Office:g* OR Office:h* OR Office:i* OR Office:j* OR Office:k* OR Office:l* OR Office:m* OR Office:n* OR Office:o* OR Office:p* OR Office:q* OR Office:r* OR Office:s* OR Office:t* OR Office:u* OR Office:v* OR Office:w* OR Office:x* OR Office:y* OR Office:z*)
or, to be specific to the query builder in the core results web part:
{searchboxquery} (Office:a* OR Office:b* OR Office:c* OR Office:d* OR Office:e* OR Office:f* OR Office:g* OR Office:h* OR Office:i* OR Office:j* OR Office:k* OR Office:l* OR Office:m* OR Office:n* OR Office:o* OR Office:p* OR Office:q* OR Office:r* OR Office:s* OR Office:t* OR Office:u* OR Office:v* OR Office:w* OR Office:x* OR Office:y* OR Office:z*) AND -Office:SVC
(FYI: that particular results page passes a wildcard "*" to the searchboxquery. I have also added an additional condition outside of the parentheses as, some legacy accounts I wanted to filter had SVC in the office field).
There may be more elegant ways to do achieve this, but it was a quick workaround and it hopefully it may help someone else with similar requirements. Just copy the query, do a find and replace of the "Office" property with your own property. If you have a text field that contains numbers and letters, you may want to add additional OR statements for 0-9