Answers.Body: <p>The light switch value should be taken out of the search query and put into the entry query:</p>
  
  <pre><code>{% set query = 'title:"' ~ "myValue" ~ '"' %}
  {% set results = craft.entries({
      section: querySections,
      search: query,
      excludeFromSearch: 'not 1',
      orderBy: 'score',
      }).limit(50) %}
  </code></pre>
  
  <p>Or slightly cleaner / Craft 3:</p>
  
  <pre><code>{% set query = 'title:"' ~ "myValue" ~ '"' %}
  {% set entryQuery = craft.entries
      .section(querySections)
      .search(query)
      .excludeFromSearch('not 1')
      .orderBy('score')
      .limit(50)
  %}
  
  {% set entries = entryQuery.all() %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-11T18:18:36.410Z
Answers.Text: Weird. It wasn't entirely clear from the documentation that you can do this. Thanks!
Answers.UserDisplayName: 4midori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-11T11:37:04.400Z
Answers.LastActivityDate: 2019-11-11T11:43:03.983Z
Answers.LastEditDate: 2019-11-11T11:43:03.983Z
Answers.UserDisplayName: dmatthams
Body: <p>I want to find all entries that match the <em>title</em> field where excludeFromSearch != 1 (is false).</p>
  
  <pre><code>{% set query = 'and excludeFromSearch not 1 and ' ~ 'title:"' ~ "myValue" ~ '"' %}
  
      {% set results = craft.entries({
      section: querySections,
      search: query,
      orderBy: 'score',
      }).limit(50) %}
  </code></pre>
  
  <p>It does not work. My field <em>excludeFromSearch</em> is a lightswitch.</p>
  
Tags: <search><query><exclude>
Title: Excluding specific field value from search
ThreadText: # Excluding specific field value from search
  
  (Asked by: username_0 on 2019-11-08)
  
  I want to find all entries that match the *title* field where excludeFromSearch != 1 (is false).
  
  ```
  {% set query = 'and excludeFromSearch not 1 and ' ~ 'title:"' ~ "myValue" ~ '"' %}
  
      {% set results = craft.entries({
      section: querySections,
      search: query,
      orderBy: 'score',
      }).limit(50) %}
  
  ```
  
  It does not work. My field *excludeFromSearch* is a lightswitch.
  
  **Tags:** search, query, exclude
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-11. Score: 4 | Accepted answer
  
  The light switch value should be taken out of the search query and put into the entry query:
  
  ```
  {% set query = 'title:"' ~ "myValue" ~ '"' %}
  {% set results = craft.entries({
      section: querySections,
      search: query,
      excludeFromSearch: 'not 1',
      orderBy: 'score',
      }).limit(50) %}
  
  ```
  
  Or slightly cleaner / Craft 3:
  
  ```
  {% set query = 'title:"' ~ "myValue" ~ '"' %}
  {% set entryQuery = craft.entries
      .section(querySections)
      .search(query)
      .excludeFromSearch('not 1')
      .orderBy('score')
      .limit(50)
  %}
  
  {% set entries = entryQuery.all() %}
  
  ```
  
  > **Comments:**
  > **username_0**: Weird. It wasn't entirely clear from the documentation that you can do this. Thanks!  
  
  ---
  
  