Answers.Body: <p>I've found that this <em>is</em> possible for lightswitch fields:</p>
  
  <p><code>craft.entries.myLightswitchField(':empty:')</code></p>
  
  <p>aka</p>
  
  <pre><code>craft.entries({
      myLightswitchField: ':empty:'
  })
  </code></pre>
  
  <p>returns all entries where the lightswitch field is toggled off <em>and</em> entries that don't have the lightswitch field.</p>
  
  <p>Not a solution for my text field need, but similar enough that it may be useful for other people.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-13T18:38:58.340Z
Answers.LastActivityDate: 2019-03-13T18:38:58.340Z
Answers.UserDisplayName: henry
Answers.Body: <p>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):</p>
  
  <pre><code>{% set entries = craft.entries.all() %}
  
  {% for entry in entries %}
  {% if entry.text is empty %}
      {{ entry.title }} &lt;br&gt;
  {% endif %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-04T22:15:42.200Z
Answers.Text: Yeah that's what pretty much what I'm doing — looping through all the results to build a new array. But like you said it's costly
Answers.UserDisplayName: henry
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-01T21:05:47.020Z
Answers.LastActivityDate: 2019-03-01T21:05:47.020Z
Answers.UserDisplayName: Oli
Body: <p>Some of my entries have the optional plaintext field <code>myCustomField</code>. I want to retrieve all entries except those where <code>myCustomField</code> is filled out.</p>
  
  <p>I can get all entries that have an empty <code>myCustomField</code></p>
  
  <pre><code>craft.entries({
      myCustomField: ':empty:',
  })
  </code></pre>
  
  <p>but that doesn't include entries that don't have the field <code>myCustomField</code>.</p>
  
Tags: <search><custom-field>
Title: how to search for entries where a custom field is either not present or is empty
ThreadText: # how to search for entries where a custom field is either not present or is empty
  
  (Asked by: username_0 on 2019-03-01)
  
  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`.
  
  **Tags:** search, custom-field
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-03-13. Score: 2
  
  I've found that this *is* possible for lightswitch fields:
  
  `craft.entries.myLightswitchField(':empty:')`
  
  aka
  
  ```
  craft.entries({
      myLightswitchField: ':empty:'
  })
  
  ```
  
  returns all entries where the lightswitch field is toggled off *and* entries that don't have the lightswitch field.
  
  Not a solution for my text field need, but similar enough that it may be useful for other people.
  
  
  ---
  
  ### Answer by username_1 on 2019-03-01. Score: 1
  
  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 }} <br>
  {% endif %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Yeah that's what pretty much what I'm doing — looping through all the results to build a new array. But like you said it's costly  
  
  ---
  
  