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):
{% set entries = craft.entries().section('yourSection') %}
{{entries.all()|length}}
{% set hasTopic = clone(entries).search('dataTable_topic:*').all() %}
{{entries|length}} | {{ hasTopic|length }}