<p>You need to specify the <a href="https://github.com/craftcms/cms/issues/1789" rel="nofollow noreferrer">fieldId of the Matrix block you're searching through</a>.</p>

<pre><code>{% set MatrixBlocks = craft.matrixBlocks()
.fieldId(123)
.type('metaData')
.search(query)
.all() %}
</code></pre>

CC BY-SA 4.0
2019-08-27T21:42:37.977Z
That did it :) Many thanks.
hvs
CC BY-SA 4.0
2019-08-27T09:02:33.280Z
2019-08-27T09:02:33.280Z
dmatthams
<p>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. </p>

<p>I tried this </p>

<pre><code> {% set MatrixBlocks = craft.matrixBlocks()
.type('metaData')
.search(query)
.all() %}
</code></pre>

<p>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.</p>

<p>What is the correct query?</p>

<matrix><queries>
How to search a matrix block with a specific handle?
# How to search a matrix block with a specific handle?

(Asked by: username_0 on 2019-08-23)

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?

**Tags:** matrix, queries

---

## 1 answers

### Answer by username_1 on 2019-08-27. Score: 2 | Accepted answer

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() %}

> **Comments:**
> **username_0**: That did it :) Many thanks.  

---

