Body: <p>In my article listing page, I have a search function. I define the article query like so:</p>
  <pre><code>{% set orderByRule = 'postDate DESC' %} {# Default order. #}
  {% if searchQuery is not null %}
      {% set orderByRule = 'score' %}
  {% endif %}
  
  {% set articleEntries = craft.entries()
      .section('articles')
      .search(search|trim)
      .orderBy(orderByRule)
      .relatedTo(categoryQuery)
      .limit(21)
  %}
  </code></pre>
  <p>The articles have a custom field called <code>articleBody</code> instead of the regular <code>body</code>.</p>
  <p>Now, the <code>searchScore</code> I get on each article seems weird to me, because it doesn't seem to care about the body text at all. However I recently realized this is probably because <code>searchScore</code> is calculated on title, slug and body, only. In other words, searchScore doesn't care about my <code>articleBody</code> field.</p>
  <p>In case it matters, my <code>config/general.php</code> file has this in terms of customization for the search functionality:</p>
  <pre class="lang-php prettyprint-override"><code>'defaultSearchTermOptions' =&gt; [
      'attribute' =&gt; 'title',
      'subLeft' =&gt; true,
      'subRight' =&gt; true,
  ],
  </code></pre>
  <p>I can find very little documentation on the subject in general to be honest. I did find <a href="https://gregorterrill.com/posts/search-scores-in-craft-cms" rel="nofollow noreferrer">this article</a>, but it doesn't talk about customizing the parameters with which searchScore is calculated.</p>
  <p>So how do I customize what pieces of content searchScore is calculated on? Can it even be done?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-05T15:06:02.440Z
Comments.Text: What kind of field is ``articleBody``? Make sure in the field settings that "use this field's values as search keywords" is [ticked](https://craftcms.com/docs/3.x/searching.html#rebuilding-your-search-indexes). Then rebuild the search index if necessary.
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-06T08:50:48.937Z
Comments.Text: @RitterKnight It's a Redactor field. It is being used for search keywords, that's not the problem. The problem is that the words within this field isn't receiving a `searchScore`.
Comments.UserDisplayName: InanisAtheos
Tags: <search>
Title: How do I customize the searchScore?
ThreadText: # How do I customize the searchScore?
  
  (Asked by: username_0 on 2022-05-04)
  
  In my article listing page, I have a search function. I define the article query like so:
  
  ```
  {% set orderByRule = 'postDate DESC' %} {# Default order. #}
  {% if searchQuery is not null %}
      {% set orderByRule = 'score' %}
  {% endif %}
  
  {% set articleEntries = craft.entries()
      .section('articles')
      .search(search|trim)
      .orderBy(orderByRule)
      .relatedTo(categoryQuery)
      .limit(21)
  %}
  
  ```
  
  The articles have a custom field called `articleBody` instead of the regular `body`.
  
  Now, the `searchScore` I get on each article seems weird to me, because it doesn't seem to care about the body text at all. However I recently realized this is probably because `searchScore` is calculated on title, slug and body, only. In other words, searchScore doesn't care about my `articleBody` field.
  
  In case it matters, my `config/general.php` file has this in terms of customization for the search functionality:
  
  ```php
  'defaultSearchTermOptions' => [
      'attribute' => 'title',
      'subLeft' => true,
      'subRight' => true,
  ],
  
  ```
  
  I can find very little documentation on the subject in general to be honest. I did find [this article](https://gregorterrill.com/posts/search-scores-in-craft-cms), but it doesn't talk about customizing the parameters with which searchScore is calculated.
  
  So how do I customize what pieces of content searchScore is calculated on? Can it even be done?
  
  **Tags:** search
  
  > **Comments:**
  > **username_1**: What kind of field is ``articleBody``? Make sure in the field settings that "use this field's values as search keywords" is [ticked](https://craftcms.com/docs/3.x/searching.html#rebuilding-your-search-indexes). Then rebuild the search index if necessary.  
  > **username_0**: @username_1 It's a Redactor field. It is being used for search keywords, that's not the problem. The problem is that the words within this field isn't receiving a `searchScore`.  
  
  ---
  
  ## 0 answers
  
  