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.

  • What version of Craft are you trying this on? – Brad Bell Aug 27 '20 at 19:01
  • Craft Pro 3.4.30 – Romain Poirier Aug 27 '20 at 19:28

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.

  • 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 Poirier Aug 28 '20 at 8:17
  • 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 Poirier Aug 28 '20 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.