Answers.Body: <p>This is because of the way Element queries are in Craft 3.</p>
  
  <p>In Craft 2, each time you called a setter method (<code>search()</code> here) it would clone your <code>ElementCriteriaModel</code>, use that value <strong>on the clone</strong> and return the cloned object leaving the original alone.</p>
  
  <p>In Craft 3, when you call a setter method, it gets set on the current element query.</p>
  
  <p>So if I understood correctly, you should use <code>clone</code> (<a href="https://docs.craftcms.com/v3/dev/functions.html#clone" rel="nofollow noreferrer">docs</a>):</p>
  
  <pre><code>{% set entries = craft.entries().section('yourSection') %}
  {{entries.all()|length}}
  
  {% set hasTopic = clone(entries).search('dataTable_topic:*').all() %}
  {{entries|length}} | {{ hasTopic|length }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-14T18:26:31.800Z
Answers.Text: Thank you! That was it
Answers.UserDisplayName: Kenyon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-14T18:02:08.830Z
Answers.LastActivityDate: 2020-02-14T18:02:08.830Z
Answers.UserDisplayName: Oli
Body: <p>Kind of hard to explain but here's an example:</p>
  
  <pre><code>{{entries.all()|length}} {# outputs 88 #}
  
  {% set hasTopic = entries.search('dataTable_topic:*').all() %}
  {{entries|length}} {# outputs 7 #}
  </code></pre>
  
  <p>How can I keep <code>entries</code> the same below the search variable.</p>
  
Tags: <search><field>
Title: Setting a field search variable after main entries variable changes values
ThreadText: # Setting a field search variable after main entries variable changes values
  
  (Asked by: username_0 on 2020-02-14)
  
  Kind of hard to explain but here's an example:
  
  ```
  {{entries.all()|length}} {# outputs 88 #}
  
  {% set hasTopic = entries.search('dataTable_topic:*').all() %}
  {{entries|length}} {# outputs 7 #}
  
  ```
  
  How can I keep `entries` the same below the search variable.
  
  **Tags:** search, field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-02-14. Score: 1 | Accepted answer
  
  This is because of the way Element queries are in Craft 3.
  
  In Craft 2, each time you called a setter method (`search()` here) it would clone your `ElementCriteriaModel`, use that value **on the clone** and return the cloned object leaving the original alone.
  
  In Craft 3, when you call a setter method, it gets set on the current element query.
  
  So if I understood correctly, you should use `clone` ([docs](https://docs.craftcms.com/v3/dev/functions.html#clone)):
  
  ```
  {% set entries = craft.entries().section('yourSection') %}
  {{entries.all()|length}}
  
  {% set hasTopic = clone(entries).search('dataTable_topic:*').all() %}
  {{entries|length}} | {{ hasTopic|length }}
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you! That was it  
  
  ---
  
  