Options for Working with Nulls
The Search API supports using the presence of a null as search criteria.
myQuery.addCriteria(cache.getAttribute("middle_name").isNull());
It also supports using the absence of a null as search criteria:
myQuery.addCriteria(cache.getAttribute("middle_name").notNull());
Which is equivalent to:
myQuery.addCriteria(cache.getAttribute("middle_name").isNull().not());
Alternatively, you can call constructors to set up equivalent logic:
Criteria isNull = new IsNull("middle_name");
Criteria notNull = new NotNull("middle_name");