Answers.Body: <p>Make sure that you checked <em>Use this field’s values as search keywords</em> under Settings → Fields → <strong>Your field</strong></p>
  <p>With that in place, run <code>./craft resave/entries --update-search-index</code> (<a href="https://craftcms.com/docs/3.x/console-commands.html#resave-entries" rel="nofollow noreferrer">docs</a>) and your entries should start showing up in your search results.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-16T14:24:02.313Z
Answers.LastActivityDate: 2020-11-16T14:24:02.313Z
Answers.UserDisplayName: Oli
Body: <p>I have a front end search which is working fine when searching titles, however when searching for text in rich text fields, or an input field <code>caseNumber</code> or the title of a related entry there are zero results.</p>
  <p>The search form has an input field where copy from the entries body or the name of the investigator (related entry) can be searched. There is also a select field that is used for categories to filter.</p>
  <p>How to get results from the related entries to display?</p>
  <p>Below is my simplified template code.</p>
  <pre><code>  &lt;section class=&quot;py-16 bg-grayBrand-lighter&quot;&gt;
      &lt;div class=&quot;container flex-col&quot;&gt;
  
  
        {% set params = {
          section: 'inventions',
          limit: 10
        } %}
  
        {% if searchQueryKeywords !=&quot;&quot; and searchQueryKeywords != null and searchQueryKeywords !=&quot;null&quot; %}
  {% set params = params | merge({
            search:'title:' ~ searchQueryKeywords ~ ' OR summary:' ~ searchQueryKeywords ~ ' OR applications:' ~ searchQueryKeywords ~ ' OR investigators:' ~ searchQueryKeywords ~ ' OR caseNumber:' ~ searchQueryKeywords,  })
          %}
        {% endif %}
  
        {#
        // get related category
        #}
        {% if searchCategory != null and searchCategory !=&quot;&quot; %}
          {% set searchQueryCategory = craft.categories.group('researchAreas').slug(searchCategory).one() %}
        {% endif %}
  
        {% if searchQueryCategory is defined %}
          {% set params = params | merge ({
            relatedTo: [
              'and',
              { targetElement: searchQueryCategory }
            ]
          }) %}
        {% endif %}
  
  
        {# set the entries with all the search/fitering params #}
            {% set entries = craft.entries(params) %}
  
        {% paginate entries as pageInfo, pageEntries %}
  
        &lt;p class=&quot;w-full mb-2 font-bold uppercase&quot;&gt;
          Search Results
        &lt;/p&gt;
  
  
  
      {#
      // let's do some math so we can display the current result count
      // so that it's 11-20 of 23 results if on page 2 with 23 results
       #}
      {% set firstCount = (pageInfo.currentPage * 10) - 9 %}
      {% set lastCount = &quot;&quot; %}
      {% for entry in pageEntries %}
        {% if loop.last %}
          {% set lastCount = firstCount + loop.length -1 %}
        {% endif %}
      {% endfor %}
      {# end math #}
  
  
        &lt;p class=&quot;mb-6&quot;&gt;
          &lt;span class=&quot;font-bold&quot;&gt;Displaying:&lt;/span&gt; &lt;span class=&quot;text-14&quot;&gt;
          {% if entries|length ==&quot;0&quot; %}
            0
          {% else %}
            {{ firstCount }} - {{ lastCount }} of {{ entries|length }}
          {% endif %}
           Results&lt;/span&gt;
        &lt;/p&gt;
  
        {% for entry in pageEntries %}
          &lt;div class=&quot;mb-8 {{ loop.last ? '':'border-b border-borderColor pb-8' }}&quot;&gt;
  
  
            &lt;div class=&quot;flex flex-col md:flex-row md:justify-between&quot;&gt;
              &lt;div class=&quot;md:mr-16 md:w-2/3&quot;&gt;
                &lt;h4 class=&quot;mb-2 leading-7 text-23&quot;&gt;&lt;a href=&quot;{{ entry.url }}&quot; class=&quot;no-underline hover:underline&quot;&gt;{{ entry.title }}&lt;/a&gt;&lt;/h4&gt;
  
                {% set summary = entry.summary|striptags %}
                &lt;p&gt;
                  {# There's a bug with truncating text - currently can only limit by characters not words. Will look into solution later #}
                  {{ seomatic.helper.truncateOnWord(summary, 250) }}
                &lt;/p&gt;
              &lt;/div&gt;
  
              &lt;div class=&quot;mt-2 md:w-1/3&quot;&gt;
                &lt;p class=&quot;font-bold text-14&quot;&gt;
                  Investigators
                &lt;/p&gt;
  
                &lt;ul&gt;
                  {% for entry in entry.investigators.all() %}
                    &lt;li class=&quot;leading-snug text-14&quot;&gt;{{ entry.firstName }} {{ entry.lastName }}&lt;/li&gt;
                  {% endfor %}
                &lt;/ul&gt;
              &lt;/div&gt;
  
            &lt;/div&gt;
  
          &lt;/div&gt;
        {% endfor %}
  
  
      {% include '_includes/pagination' with {
            fullWidth:false,
          } %}
  
  
  
      &lt;/div&gt;&lt;!-- /.container --&gt;
    &lt;/section&gt;&lt;!-- /.py-16 --&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-11-09T10:35:22.700Z
Comments.Text: Could it be because you are hard-setting `section: 'inventions',` in your `params`?
Comments.UserDisplayName: Oli
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-11-09T15:05:25.007Z
Comments.Text: @Oli I would expect that results would show since entries have relationships to the investigators and in this case I want to show results where the investigators field in the inventions channel has the correct person.
Comments.UserDisplayName: CreateSean
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-11-10T13:09:50.120Z
Comments.Text: Oh, I see, I thought you wanted entries from another section. Can you try to re-index your entries just to make sure `./craft resave/entries --update-search-index`.
Comments.UserDisplayName: Oli
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-11-10T17:06:37.937Z
Comments.Text: I tried that before posting this and it didn't work. @oli should I send an email directly to support?
Comments.UserDisplayName: CreateSean
Tags: <relations><search>
Title: Front End Search Related Entries
ThreadText: # Front End Search Related Entries
  
  (Asked by: username_0 on 2020-11-06)
  
  I have a front end search which is working fine when searching titles, however when searching for text in rich text fields, or an input field `caseNumber` or the title of a related entry there are zero results.
  
  The search form has an input field where copy from the entries body or the name of the investigator (related entry) can be searched. There is also a select field that is used for categories to filter.
  
  How to get results from the related entries to display?
  
  Below is my simplified template code.
  
  ```
    <section class="py-16 bg-grayBrand-lighter">
      <div class="container flex-col">
  
        {% set params = {
          section: 'inventions',
          limit: 10
        } %}
  
        {% if searchQueryKeywords !="" and searchQueryKeywords != null and searchQueryKeywords !="null" %}
  {% set params = params | merge({
            search:'title:' ~ searchQueryKeywords ~ ' OR summary:' ~ searchQueryKeywords ~ ' OR applications:' ~ searchQueryKeywords ~ ' OR investigators:' ~ searchQueryKeywords ~ ' OR caseNumber:' ~ searchQueryKeywords,  })
          %}
        {% endif %}
  
        {#
        // get related category
        #}
        {% if searchCategory != null and searchCategory !="" %}
          {% set searchQueryCategory = craft.categories.group('researchAreas').slug(searchCategory).one() %}
        {% endif %}
  
        {% if searchQueryCategory is defined %}
          {% set params = params | merge ({
            relatedTo: [
              'and',
              { targetElement: searchQueryCategory }
            ]
          }) %}
        {% endif %}
  
        {# set the entries with all the search/fitering params #}
            {% set entries = craft.entries(params) %}
  
        {% paginate entries as pageInfo, pageEntries %}
  
        <p class="w-full mb-2 font-bold uppercase">
          Search Results
        </p>
  
      {#
      // let's do some math so we can display the current result count
      // so that it's 11-20 of 23 results if on page 2 with 23 results
       #}
      {% set firstCount = (pageInfo.currentPage * 10) - 9 %}
      {% set lastCount = "" %}
      {% for entry in pageEntries %}
        {% if loop.last %}
          {% set lastCount = firstCount + loop.length -1 %}
        {% endif %}
      {% endfor %}
      {# end math #}
  
        <p class="mb-6">
          <span class="font-bold">Displaying:</span> <span class="text-14">
          {% if entries|length =="0" %}
            0
          {% else %}
            {{ firstCount }} - {{ lastCount }} of {{ entries|length }}
          {% endif %}
           Results</span>
        </p>
  
        {% for entry in pageEntries %}
          <div class="mb-8 {{ loop.last ? '':'border-b border-borderColor pb-8' }}">
  
            <div class="flex flex-col md:flex-row md:justify-between">
              <div class="md:mr-16 md:w-2/3">
                <h4 class="mb-2 leading-7 text-23"><a href="{{ entry.url }}" class="no-underline hover:underline">{{ entry.title }}</a></h4>
  
                {% set summary = entry.summary|striptags %}
                <p>
                  {# There's a bug with truncating text - currently can only limit by characters not words. Will look into solution later #}
                  {{ seomatic.helper.truncateOnWord(summary, 250) }}
                </p>
              </div>
  
              <div class="mt-2 md:w-1/3">
                <p class="font-bold text-14">
                  Investigators
                </p>
  
                <ul>
                  {% for entry in entry.investigators.all() %}
                    <li class="leading-snug text-14">{{ entry.firstName }} {{ entry.lastName }}</li>
                  {% endfor %}
                </ul>
              </div>
  
            </div>
  
          </div>
        {% endfor %}
  
      {% include '_includes/pagination' with {
            fullWidth:false,
          } %}
  
      </div><!-- /.container -->
    </section><!-- /.py-16 -->
  
  ```
  
  **Tags:** relations, search
  
  > **Comments:**
  > **username_1**: Could it be because you are hard-setting `section: 'inventions',` in your `params`?  
  > **username_0**: @username_1 I would expect that results would show since entries have relationships to the investigators and in this case I want to show results where the investigators field in the inventions channel has the correct person.  
  > **username_1**: Oh, I see, I thought you wanted entries from another section. Can you try to re-index your entries just to make sure `./craft resave/entries --update-search-index`.  
  > **username_0**: I tried that before posting this and it didn't work. @oli should I send an email directly to support?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-16. Score: 3 | Accepted answer
  
  Make sure that you checked *Use this field’s values as search keywords* under Settings → Fields → **Your field**
  
  With that in place, run `./craft resave/entries --update-search-index` ([docs](https://craftcms.com/docs/3.x/console-commands.html#resave-entries)) and your entries should start showing up in your search results.
  
  
  ---
  
  