how to search for entries where a custom field is either not present or is empty Some of my entries have the optional plaintext field myCustomField. I want to retrieve all entries except those where myCustomField is filled out.

I can get all entries that have an empty myCustomField

craft.entries({
    myCustomField: ':empty:',
})


but that doesn't include entries that don't have the field myCustomField.
I don't know if you can do that at query level without adding the field to your other sections but you can do (although it's not very economical):

{% set entries = craft.entries.all() %}

{% for entry in entries %}
{% if entry.text is empty %}
    {{ entry.title }} &lt;br&gt;
{% endif %}
{% endfor %}