I want to exclude some entires from search, so I add a field hideFromSearch and enable Use this field’s values as search keywords

It works when I search like


But it doesn't work when I search like


Always return empty array. I also tried


No luck.

Craft version: Craft Pro

1 Answer 1


Instead of adding the lightswitch field to the search query, add a separate condition as recommended in the documentation.

    ->search('my search query')

Use true and false to only find entries where the lightswitch is turned on or off, respectively. Then you can deselect Use this field’s values as search keywords, as this condition won't require the search index.

  • 1
    Work like a charm, thanks
    – Thomas
    Commented Jan 13, 2023 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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