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?

1 Answer 1

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() %}
1
  • That did it :) Many thanks.
    – hvs
    Aug 27, 2019 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.