1

I want to query a specific matrix block using text search which will search all the searchable fields in that particular block and give me output in the form of blocks that I can further process.

I tried this

 {% set MatrixBlocks = craft.matrixBlocks()
.type('metaData')
.search(query)
.all() %}

But when I dump each block, I am seeing so many fields and not fields only from the particuar block (metaData) that I want to query.

What is the correct query?

2
+50

You need to specify the fieldId of the Matrix block you're searching through.

{% set MatrixBlocks = craft.matrixBlocks()
.fieldId(123)
.type('metaData')
.search(query)
.all() %}
| improve this answer | |
  • That did it :) Many thanks. – hvs Aug 27 '19 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.