Answers.Body: <p>To be honest, those two parameters may seem to be slightly similar but provide a totally different functionality.</p>
  <p>From their documentation on search:</p>
  <blockquote>
  <p><strong>search</strong></p>
  <p>Only fetch entries that match a given search query. (See Searching for the syntax and &gt; available search attributes.)</p>
  </blockquote>
  <p>Which means whatever you pass in <code>.search(query)</code>, and there is a rather complex list <a href="http://buildwithcraft.com/docs/searching" rel="noreferrer">here</a>, will actually 'search' Craft for the query string you specify.</p>
  <p>On a different note,</p>
  <blockquote>
  <p><strong>relatedTo</strong></p>
  <p>Only fetch entries that are related to certain other elements. (See
  Relations for the syntax options.)</p>
  </blockquote>
  <p>This on the other hand only 'relates' to other entries, meaning its not performing a fill search on Craft, only the entries. A detailed reference on relations can be found <a href="http://buildwithcraft.com/docs/relations" rel="noreferrer">here</a>.</p>
  <p>As far as performance, the two are unrelated as it really depends on what you are trying to accomplish.</p>
  <p>Hope this clears it up for you!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-25T17:03:29.467Z
Answers.Text: Using search is going to be slower in about 99% of the cases as it's doing a MySQL Full Text Search (https://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html), an inherently slow operation.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-25T17:25:01.073Z
Answers.Text: Excellent point Brad.
Answers.UserDisplayName: Jason McCallister
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-25T09:30:23.723Z
Answers.LastActivityDate: 2014-07-25T09:30:23.723Z
Answers.LastEditDate: 2020-06-17T08:56:27.903Z
Answers.UserDisplayName: Jason McCallister
Body: <p>I have problems to understand the difference between search and relatedTo. From my understanding, this is a fulltext search on all fields.</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% set entries = craft.entries.search(test).order('score') %}
  </code></pre>
  
  <p>Does the following approach mean the same?</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% set entries = craft.entries.relatedTo(test).order('score').find() %}
  </code></pre>
  
  <p>And if yes, which one delivers the better performance?</p>
  
  <p>Thanks!</p>
  
Tags: <search><performance><relations>
Title: Using “search” vs. “relatedTo” in a template
ThreadText: # Using “search” vs. “relatedTo” in a template
  
  (Asked by: username_0 on 2014-07-25)
  
  I have problems to understand the difference between search and relatedTo. From my understanding, this is a fulltext search on all fields.
  
  ```twig
  {% set entries = craft.entries.search(test).order('score') %}
  
  ```
  
  Does the following approach mean the same?
  
  ```twig
  {% set entries = craft.entries.relatedTo(test).order('score').find() %}
  
  ```
  
  And if yes, which one delivers the better performance?
  
  Thanks!
  
  **Tags:** search, performance, relations
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-25. Score: 10 | Accepted answer
  
  To be honest, those two parameters may seem to be slightly similar but provide a totally different functionality.
  
  From their documentation on search:
  
  > **search**
  >
  > Only fetch entries that match a given search query. (See Searching for the syntax and > available search attributes.)
  
  Which means whatever you pass in `.search(query)`, and there is a rather complex list [here](http://buildwithcraft.com/docs/searching), will actually 'search' Craft for the query string you specify.
  
  On a different note,
  
  > **relatedTo**
  >
  > Only fetch entries that are related to certain other elements. (See
  > Relations for the syntax options.)
  
  This on the other hand only 'relates' to other entries, meaning its not performing a fill search on Craft, only the entries. A detailed reference on relations can be found [here](http://buildwithcraft.com/docs/relations).
  
  As far as performance, the two are unrelated as it really depends on what you are trying to accomplish.
  
  Hope this clears it up for you!
  
  > **Comments:**
  > **username_2**: Using search is going to be slower in about 99% of the cases as it's doing a MySQL Full Text Search (https://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html), an inherently slow operation.  
  > **username_1**: Excellent point username_2.  
  
  ---
  
  