Typically empty + null values are not stored in the Lucene index, it's really designed for queries that are finding data rather than the absence of it. If you searched for +fieldName:*
then that should find documents which have an entry (and therefore value) for fieldName.
I'm not entirely sure how the query-builder maps the query, it looks like judging by your example what you'd want is +custom:fieldName|*
If this doesn't work, Sitecore does have a mechanism of allowing you to specify a string value that takes the place of empty / null when indexing, therefore giving you something to search for. To do this you will need to add the field to the index manually in your indexing configuration, specifying the string to use as the "empty" value:
<field fieldName="title" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String"
nullValue="NULLVALUE" emptyString="EMPTYVALUE" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
You should then be able to filter these documents out of a search using -custom:title|NULLVALUE -custom:title|EMPTYVALUE
.
A drawback with this approach is that you want these two strings to be values that your field value will never genuinely be!
More information can be found here - https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/search_and_item_buckets/queries_for_null_or_empty_strings
Sitecore Query
or is this a Lucene/Solr query - it doesn't look likeSitecore Query
to me,