Answers.Body: <p>Instead of adding the filtering criteria to the search parameter, I would use a custom field parameter for the <code>showInSearch</code> field.</p>
  
  <pre><code>{% set miniCards = craft.entries.search(query).showInSearch('not 1').limit(12) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-01T14:58:43.780Z
Answers.LastActivityDate: 2016-02-01T14:58:43.780Z
Answers.UserDisplayName: carlcs
Body: <p>This is my search results query:</p>
  
  <pre><code>{% set query = craft.request.getParam('q') %}
  {% set miniCards = craft.entries.search(query).order('score').limit(12) %}
  </code></pre>
  
  <p>I have a lightswitch field called <code>showInSearch</code>. When it is set to <code>1</code> the entry should not appear in search results. </p>
  
  <p><strong>Problem</strong><br>
  When I do this I always get zero results on my searches:</p>
  
  <pre><code>{% set query = craft.request.getParam('q') %}
  {% set miniCards = craft.entries.search(query ~' -showInSearch:1').order('score').limit(12) %}
  </code></pre>
  
  <p>Whereas when I do the opposite I get all results with the search term <em>and</em> the lightswitch field set to <code>1</code>.</p>
  
  <pre><code>{% set query = craft.request.getParam('q') %}
  {% set miniCards = craft.entries.search(query ~' showInSearch:1').order('score').limit(12) %}
  </code></pre>
  
  <p>I also tried <code>-showInSearch::1</code>,<code>-showInSearch::"1"</code>, <code>-showInSearch:"1"</code> and <code>showInSearch:0</code> to no avail. What am I doing wrong?</p>
  
  <p>Problem persists even after rebuilding search indexes.</p>
  
Tags: <entries><search>
Title: Hide search results depending on field value
ThreadText: # Hide search results depending on field value
  
  (Asked by: username_0 on 2016-02-01)
  
  This is my search results query:
  
  ```
  {% set query = craft.request.getParam('q') %}
  {% set miniCards = craft.entries.search(query).order('score').limit(12) %}
  
  ```
  
  I have a lightswitch field called `showInSearch`. When it is set to `1` the entry should not appear in search results.
  
  **Problem**  
  When I do this I always get zero results on my searches:
  
  ```
  {% set query = craft.request.getParam('q') %}
  {% set miniCards = craft.entries.search(query ~' -showInSearch:1').order('score').limit(12) %}
  
  ```
  
  Whereas when I do the opposite I get all results with the search term *and* the lightswitch field set to `1`.
  
  ```
  {% set query = craft.request.getParam('q') %}
  {% set miniCards = craft.entries.search(query ~' showInSearch:1').order('score').limit(12) %}
  
  ```
  
  I also tried `-showInSearch::1`,`-showInSearch::"1"`, `-showInSearch:"1"` and `showInSearch:0` to no avail. What am I doing wrong?
  
  Problem persists even after rebuilding search indexes.
  
  **Tags:** entries, search
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-02-01. Score: 4 | Accepted answer
  
  Instead of adding the filtering criteria to the search parameter, I would use a custom field parameter for the `showInSearch` field.
  
  ```
  {% set miniCards = craft.entries.search(query).showInSearch('not 1').limit(12) %}
  
  ```
  
  
  ---
  
  