With element queries, we can search for elements using search method:


or by using field handle as method:


How these two techniques are different from each other and when whould we use each?

1 Answer 1


The search parameter gives you an entire range of search functionality, as explained in the docs at https://craftcms.com/docs/3.x/searching.html

Using a field handle as a parameter essentially specifies what the value of the field must equates to. How this is determined can vary, based on the field type, but in most cases it will be an exact match.

So in the following example, only entries with the exact plaintext field value something will be returned.


If you dump the query's raw SQL then you will see this.

{{ dump(craft.entries.somePlaintextField('something').getRawSql()) }}

Outputs: SELECT ... WHERE ... AND (`content`.`field_somePlaintextField`='something') ...

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.