<p>Lightswitch fields are a bit of an edge-case in searching because it can only be true/false (in the real boolean sense of true/false) so Craft doesn't explicitly index it in the searchindex table.</p>
<p>That's a bit awkward because even through there is a field setting &quot;use this field's value for the search index&quot; it's the one field where it doesn't apply.</p>
<p>Regardless, this should all be rectified for the upcoming Craft 4 release where we plan to make this possible.</p>

CC BY-SA 4.0
2020-08-28T08:17:51.253Z
Thank you Brad. In my case, I was primary looking for Lightswitch values that were TRUE and were returning nothing. In fact, the search index feature was disabled for this field, and you pointed it out. Now `fieldHandle:1` returns something. That's (almost) enough for me :)
Romain P.
CC BY-SA 4.0
2020-08-28T08:19:28.217Z
Just one more thing: after enable the search index again for this field, `./craft resave/users` and `./craft resave/entries` had not the expected effect. The Lightswitch field values were still not indexed. I had to re-save manually these Entries to get the index up to date.
Romain P.
CC BY-SA 4.0
2020-08-27T21:52:22.387Z
2020-08-27T21:52:22.387Z
Brad Bell
<p>I tried these kind of searches in the CP search field (on top of the Entry list):</p>
<ul>
<li>fieldHandle:true / fieldHandle:false</li>
<li>fieldHandle:1 / fieldHandle:0</li>
<li>fieldHandle:* / -fieldHandle:*</li>
<li>fieldHandle:not 1 / fieldHandle:'not 1'</li>
<li>etc.</li>
</ul>
<p>Unfortunately, none of these returns the expected entries.</p>

CC BY-SA 4.0
2020-08-27T19:01:07.340Z
What version of Craft are you trying this on?
Brad Bell
CC BY-SA 4.0
2020-08-27T19:28:26.857Z
Craft Pro 3.4.30
Romain P.
<control-panel><search><lightswitch>
Within the CP, how can I filter the listed Entries based on a Lightswitch field value?
# Within the CP, how can I filter the listed Entries based on a Lightswitch field value?

(Asked by: username_0 on 2020-08-27)

I tried these kind of searches in the CP search field (on top of the Entry list):

* fieldHandle:true / fieldHandle:false
* fieldHandle:1 / fieldHandle:0
* fieldHandle:\* / -fieldHandle:\*
* fieldHandle:not 1 / fieldHandle:'not 1'
* etc.

Unfortunately, none of these returns the expected entries.

**Tags:** control-panel, search, lightswitch
> **Comments:**
> **username_1**: What version of Craft are you trying this on?  
> **username_0**: Craft Pro 3.4.30  

---

## 1 answers

### Answer by username_1 on 2020-08-27. Score: 0

Lightswitch fields are a bit of an edge-case in searching because it can only be true/false (in the real boolean sense of true/false) so Craft doesn't explicitly index it in the searchindex table.

That's a bit awkward because even through there is a field setting "use this field's value for the search index" it's the one field where it doesn't apply.

Regardless, this should all be rectified for the upcoming Craft 4 release where we plan to make this possible.

> **Comments:**
> **username_0**: Thank you Brad. In my case, I was primary looking for Lightswitch values that were TRUE and were returning nothing. In fact, the search index feature was disabled for this field, and you pointed it out. Now `fieldHandle:1` returns something. That's (almost) enough for me :)  
> **username_0**: Just one more thing: after enable the search index again for this field, `./craft resave/users` and `./craft resave/entries` had not the expected effect. The Lightswitch field values were still not indexed. I had to re-save manually these Entries to get the index up to date.  

---

