<p>As far as I know (please correct me if I missed something) you can only search for the entire matrix by <code>matrixField:value</code> and not certain fields within your matrix since the table <code>searchindexes</code> only contains the id of the matrix field itself, not the id of the field inside the matrix.</p>

<p>However: you could create a <code>Query</code> from your <code>ElementCriteriaModel</code> in PHP via</p>

<pre><code>$command = craft()-&gt;elements-&gt;buildElementsQuery($criteria);
</code></pre>

<p>Join your matrixblock table as well as your matrixblock content table</p>

<pre><code>$command-&gt;join("your matrixTable", "matrixTable.ownerId = elements.id");
$command-&gt;join("your matrixContentTable", "matrixContentTable.elementId = matrixTable.id");
</code></pre>

<p>And search for your field with a <code>where</code></p>

<pre><code>$command-&gt;andWhere('MyAwesomeField LIKE %whatever%');
</code></pre>

CC BY-SA 4.0
2018-05-21T13:16:43.180Z
2018-05-21T13:16:43.180Z
Robin Schambach
<p>Can’t believe this is the first time I’ve had to do this, but I need to search a field inside a matrix and I can’t find any documentation on this. Craft 2 if that matters. I had hoped something like </p>

<blockquote>
  <p>craft.entries.search('matrixField:field:value')</p>
</blockquote>

<p>would work but doesn’t seem to. Anyone help me out?</p>

<matrix>
Searching Matrix field
# Searching Matrix field

(Asked by: username_0 on 2018-05-21)

Can’t believe this is the first time I’ve had to do this, but I need to search a field inside a matrix and I can’t find any documentation on this. Craft 2 if that matters. I had hoped something like

> craft.entries.search('matrixField:field:value')

would work but doesn’t seem to. Anyone help me out?

**Tags:** matrix

---

## 1 answers

### Answer by username_1 on 2018-05-21. Score: 1

As far as I know (please correct me if I missed something) you can only search for the entire matrix by matrixField:value and not certain fields within your matrix since the table searchindexes only contains the id of the matrix field itself, not the id of the field inside the matrix.
However: you could create a Query from your ElementCriteriaModel in PHP via
$command = craft()->elements->buildElementsQuery($criteria);

Join your matrixblock table as well as your matrixblock content table
$command->join("your matrixTable", "matrixTable.ownerId = elements.id");
$command->join("your matrixContentTable", "matrixContentTable.elementId = matrixTable.id");

And search for your field with a where
$command->andWhere('MyAwesomeField LIKE %whatever%');


---

