Answers.Body: <p>I think you need to make two separate queries, get two arrays, combine them using the <code>merge</code> method and leave them unique, since these are different searches, textual and by related elements. It's like a quick fix, if I find something I will answer.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-17T05:39:15.887Z
Answers.Text: OK, thank you. I am not very good with craft cms, working on it for the first time, so no idea how to do the merge but I will take a look at documentation
Answers.UserDisplayName: aslamdoctor
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-16T16:06:46.000Z
Answers.LastActivityDate: 2020-07-16T16:06:46.000Z
Answers.UserDisplayName: Pavel Pavlovich
Body: <p>I want to do a search query so the product title or product tag name matches the keyword. below is my code. if I remove the tag related query, this code works as it looks into the product title only and returns the result. But how to make it work so it looks for the keyword in both product title and tag name? and if it exists in any one, it results specific records?</p>
  <pre><code> {% set productValues = {
          keywords: craft.app.request.getParam('keywords'),
          orderBy: craft.app.request.getParam('order') ? craft.app.request.getParam('order') : 'score'
      } %}
      
      {% set tag = craft.tags.search(craft.app.request.getParam('keywords')).first() %}
  
      {% set productParameters = {
          search: 'title:' ~ productValues.keywords,
          relatedTo: [
              'OR',
              tag
          ],
          orderBy: productValues.order
   }%}
  </code></pre>
  
Tags: <craft3><plugin-craftcommerce>
Title: How to search by title OR tag using Craft CMS?
ThreadText: # How to search by title OR tag using Craft CMS?
  
  (Asked by: username_0 on 2020-07-16)
  
  I want to do a search query so the product title or product tag name matches the keyword. below is my code. if I remove the tag related query, this code works as it looks into the product title only and returns the result. But how to make it work so it looks for the keyword in both product title and tag name? and if it exists in any one, it results specific records?
  
  ```
   {% set productValues = {
          keywords: craft.app.request.getParam('keywords'),
          orderBy: craft.app.request.getParam('order') ? craft.app.request.getParam('order') : 'score'
      } %}
      
      {% set tag = craft.tags.search(craft.app.request.getParam('keywords')).first() %}
  
      {% set productParameters = {
          search: 'title:' ~ productValues.keywords,
          relatedTo: [
              'OR',
              tag
          ],
          orderBy: productValues.order
   }%}
  
  ```
  
  **Tags:** craft3, plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-07-16. Score: 1
  
  I think you need to make two separate queries, get two arrays, combine them using the `merge` method and leave them unique, since these are different searches, textual and by related elements. It's like a quick fix, if I find something I will answer.
  
  > **Comments:**
  > **username_0**: OK, thank you. I am not very good with craft cms, working on it for the first time, so no idea how to do the merge but I will take a look at documentation  
  
  ---
  
  