Answers.Body: <p>To make fields inside matrix blocks searchable, you need to check <code>Use this field’s values as search keywords?</code> both for the fields inside the matrix as well as for the matrix field itself. Your screenshot only shows the checkbox checked for a nested field, so make sure the matrix field is searchable as well. If the matrix field itself is not searchable, setting the fields inside it to searchable won't have any effect.</p>
  <p>From the documentation:</p>
  <blockquote>
  <p>For Matrix fields, the top-level <strong>Use this field’s values as search keywords</strong> setting determines whether any sub-fields will factor into results for the parent. For relational fields like Assets, Categories, and Entries, the setting determines whether related titles should factor into search results.</p>
  </blockquote>
  <p><a href="https://craftcms.com/docs/3.x/searching.html#configuring-custom-fields-for-search" rel="nofollow noreferrer">Source</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-11T11:24:48.497Z
Answers.LastActivityDate: 2021-08-11T11:24:48.497Z
Answers.UserDisplayName: MoritzLost
Body: <p>I have a frontend search form and I want to search within a matrix block. I have checked the box to make this field searchable.
  <a href="https://i.sstatic.net/dI16E.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dI16E.png" alt="enter image description here" /></a></p>
  <p>And I'm using the expanded search plugin.</p>
  <p>Here is my results code</p>
  <pre><code>{% set query = craft.app.request.getParam('q') %}
  
    {% set expandedResults = craft.expandedSearch.search(query) %}
    {% for result in expandedResults %}
        &lt;strong data-field=&quot;{{result.matchedField}}&quot;&gt;{{result.entry.title}}&lt;/strong&gt;&lt;br&gt;
        &lt;p&gt;{{result.matchedValue}}&lt;/p&gt;
        &lt;a href=&quot;{{result.entry.url}}&quot;&gt;{{result.entry.url}}&lt;/a&gt;
    {% else %}
        &lt;p&gt;Sorry, no results for {{query}}.&lt;/p&gt;
    {% endfor %}
  </code></pre>
  <p>Now if I try to search for a specific word from my content, the search result shows only the Entries that have the query word in their title, but not inside content.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T11:22:13.940Z
Comments.Text: Have you marked both the field inside the matrix as well as the matrix field itself as searchable?
Comments.UserDisplayName: MoritzLost
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T11:34:44.017Z
Comments.Text: Actually I didn't do that, but I did it just now, but the search still doesn't work. I would also expect to have a search reindex, but I don't see that.
Comments.UserDisplayName: loliki
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T12:41:43.733Z
Comments.Text: Not sure if the search index is updated automatically when changing settings. You can use the [resave command](https://craftcms.com/docs/3.x/console-commands.html#resave-entries) to save all entries, forcing an update to the search index: `php craft resave/entries --update-search-index`. Also, search indexes are updated asynchronously using a queue job, so make sure you have a [queue listener](https://craftcms.com/docs/3.x/console-commands.html#queue-listen) active on your development machine so the queue jobs are actually processed.
Comments.UserDisplayName: MoritzLost
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T19:00:39.890Z
Comments.Text: Perfect, thanks a lot, now everything works fine :)
Comments.UserDisplayName: loliki
Tags: <craft3><search>
Title: Search within matrix Block content
ThreadText: # Search within matrix Block content
  
  (Asked by: username_0 on 2021-08-11)
  
  I have a frontend search form and I want to search within a matrix block. I have checked the box to make this field searchable.
  [![enter image description here](https://i.sstatic.net/dI16E.png)](https://i.sstatic.net/dI16E.png)
  
  And I'm using the expanded search plugin.
  
  Here is my results code
  
  ```
  {% set query = craft.app.request.getParam('q') %}
  
    {% set expandedResults = craft.expandedSearch.search(query) %}
    {% for result in expandedResults %}
        <strong data-field="{{result.matchedField}}">{{result.entry.title}}</strong><br>
        <p>{{result.matchedValue}}</p>
        <a href="{{result.entry.url}}">{{result.entry.url}}</a>
    {% else %}
        <p>Sorry, no results for {{query}}.</p>
    {% endfor %}
  
  ```
  
  Now if I try to search for a specific word from my content, the search result shows only the Entries that have the query word in their title, but not inside content.
  
  **Tags:** craft3, search
  
  > **Comments:**
  > **username_1**: Have you marked both the field inside the matrix as well as the matrix field itself as searchable?  
  > **username_0**: Actually I didn't do that, but I did it just now, but the search still doesn't work. I would also expect to have a search reindex, but I don't see that.  
  > **username_1**: Not sure if the search index is updated automatically when changing settings. You can use the [resave command](https://craftcms.com/docs/3.x/console-commands.html#resave-entries) to save all entries, forcing an update to the search index: `php craft resave/entries --update-search-index`. Also, search indexes are updated asynchronously using a queue job, so make sure you have a [queue listener](https://craftcms.com/docs/3.x/console-commands.html#queue-listen) active on your development machine so the queue jobs are actually processed.  
  > **username_0**: Perfect, thanks a lot, now everything works fine :)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-08-11. Score: 2 | Accepted answer
  
  To make fields inside matrix blocks searchable, you need to check `Use this field’s values as search keywords?` both for the fields inside the matrix as well as for the matrix field itself. Your screenshot only shows the checkbox checked for a nested field, so make sure the matrix field is searchable as well. If the matrix field itself is not searchable, setting the fields inside it to searchable won't have any effect.
  
  From the documentation:
  
  > For Matrix fields, the top-level **Use this field’s values as search keywords** setting determines whether any sub-fields will factor into results for the parent. For relational fields like Assets, Categories, and Entries, the setting determines whether related titles should factor into search results.
  
  [Source](https://craftcms.com/docs/3.x/searching.html#configuring-custom-fields-for-search)
  
  
  ---
  
  