Searching for empty managed metadata columns can now be achieved.
When working with SharePoint search programmatically, one weakness that developers often face is the inability to query for “null” or empty values. One solution I saw when performing some maintenance on a client’s (heavily customised) intranet was to do a NOT match against a*, b*, c*… z*. This worked for their usage, but it was a bit ugly, and the resulting query was enormous. Additionally, it only gets more complex if we consider that not all of our data will start with alphabetical characters.
When working with managed metadata, I found that a far more elegant solution was to query a managed property mapped to the a taxonomy ID crawled property (eg: ows_taxId_MyColumn). When content is tagged with data, this managed property will look something like this:
Content with a value will always start with G, so we can do a search for items that do not start with G to match all blank selections. This might look like:
Using the taxonomy ID also gives us the ability to do exact matches against terms using ‘#0’ (helpful when there are multiple terms that share a label), or match all children of a particular term ‘#’.