Trying to search through a Matrix field, currently I am using conditionals to accomplish this, but if it's faster would like to limit the results to only what I need.

{% for row in entry.matrixField.search(matrixChild1:"mykeyword") %}

{% set getResults = row.matrixChild1.one.slug %}

{% endfor %}

I could not find much on this, I know a search() parametered can be used in Matrix but after all my trying still nothing. Hopefully it's possible?

1 Answer 1


Please take a look at the docs there are so many examples how to search here at stack exchange and it's well explained in the docs. I posted the same answer multiple times within the last days


As I already said a few times too "looping through queries is still deprecated". Please fetch your results with .all() or .one(). There is no reason to fill your logs with deprecated warnings - you won't have any benefits

  • My apologies, I did not seem to get it and I looked through the docs, thankfully good peeps like you are here to help out. I spend a ton of time trying to get the answer before I ever post it on here.
    – Vin
    Commented May 12, 2018 at 10:07
  • Were you able to make it work now? Commented May 12, 2018 at 11:13
  • Sort of. What I really need and would be epic is to get the matching done in the craft.entries tag. I am 90% finished with my project and being so close I am so far away. The solution you provided elsewhere I did not realize did not work as I expected. {% set entries = craft.entries.section('flightcompany').relatedTo('and', { targetElement: models, field: 'partsModels.model' }, { targetElement: parts, field: 'partsModels.part' } ) %} craftcms.stackexchange.com/questions/26107/…
    – Vin
    Commented May 12, 2018 at 19:02
  • What do you mean by craft.entries tag? craft.entries returns nearly the same type of object like entry.matrixField you can use the same syntax and the same parameters since both are ElementQueries. Maybe you should learn to provide proper feedback. My query will return all elements that contains mykeyword Commented May 12, 2018 at 19:08
  • Meaning the order in which I call the tags. I have 80,000+ records, so looping through each entry and each entry has 10+ matrix records, in those records is 1 table 2 category fields. The table field can have 10-20 records each as text. So it's pulling in the records from my main records in entries which there are 600+ of those. So I am having to grab the main record and loop through each looking for specific records and writing conditionals to get only records meeting those conditions.
    – Vin
    Commented May 12, 2018 at 21:38

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.