Answers.Body: <p>I gave this a quick test, and it seems that Craft only searches the title field of related assets, when searching entries. What you could do, is first search for all entries with your search term, then all assets with the search term AND related to an entry. Combine those to sets of ids, and you're all set (not really one line of code, though):</p>
  
  <pre><code>{# your search term #}
  {% set searchTerm = craft.request.param('q') %}
  
  {# first, search all entries with given search term #}
  {% set entries = craft.entries.search(searchTerm).ids() %}
  
  {# first, search all assets with given search term and their relations #}
  {% set assets = craft.assets.search(searchTerm).ids() %}
  {% set entriesRelatedToAssets = craft.entries.relatedTo(assets).ids() %}
  
  {# Combine those ids to one array #}
  {% set allIds = entries | merge(entriesRelatedToAssets) %}
  
  {# Then get all the entries with the given IDs #}
  {% for entry in craft.entries.id(allIds) %}
      {{ entry.title }}&lt;br /&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-02T15:20:06.660Z
Answers.Text: This is the idea I had which is totally okay. I guess what I'm trying to do can't really be done with one line of code? Thanks for the code sample!
Answers.UserDisplayName: naboovalley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-02T15:22:20.940Z
Answers.Text: Someone MIGHT know some `search()` tricks to also search custom fields in related elements. Then it could be done with one line of code. Maybe an email to P&T could give some clarity.
Answers.UserDisplayName: Paul
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-02T15:37:24.397Z
Answers.Text: How do you think this code will behave/perform when searching through let's say 100,000 entries? Template overload? :P
Answers.UserDisplayName: naboovalley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-02T15:39:17.950Z
Answers.Text: Don't know. Using `.ids()` is better (performance-wise) than getting all the objects, but you'd have to test it to be sure.
Answers.UserDisplayName: Paul
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-02T15:18:43.517Z
Answers.LastActivityDate: 2015-02-02T15:18:43.517Z
Answers.UserDisplayName: Paul
Body: <p>I have three (3) different channels. One (1) channel have Assets attached to it, and those Assets have a couple of fields attached to them as well.</p>
  
  <p>How can I make the broadest possible search on all these channels (and the channels Assets and fields) using the <strong>.search()</strong> function?</p>
  
  <p>For clarification; I want to make a search in all channels, and their Assets (and the Assets own fields) with (if possible) one single line of code.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-02T14:29:25.070Z
Comments.Text: Hey there! What do you mean by the "channel have Assets attached to it?" Are there just entries inside that channel that have assets?
Comments.UserDisplayName: Aaron Berkowitz
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-02T15:02:00.290Z
Comments.Text: The channel has a "Asset" field type attached to it. The added assets (through this field) have their own fields as well. Thanks.
Comments.UserDisplayName: naboovalley
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-02T15:14:18.817Z
Comments.Text: Ok cool. What are you hoping to return? Entries, assets, or both?
Comments.UserDisplayName: Aaron Berkowitz
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-02T15:18:45.807Z
Comments.Text: I would like to return entries, but the search would include the searching through the fields for the added assets as well. It not possible I guess I can always run a search() on both entries and assets and combine the result in the template. But would like to avoid it if possible :)
Comments.UserDisplayName: naboovalley
Tags: <entries><assets><search>
Title: How can I make the broadest search possible?
ThreadText: # How can I make the broadest search possible?
  
  (Asked by: username_0 on 2015-02-02)
  
  I have three (3) different channels. One (1) channel have Assets attached to it, and those Assets have a couple of fields attached to them as well.
  
  How can I make the broadest possible search on all these channels (and the channels Assets and fields) using the **.search()** function?
  
  For clarification; I want to make a search in all channels, and their Assets (and the Assets own fields) with (if possible) one single line of code.
  
  **Tags:** entries, assets, search
  
  > **Comments:**
  > **username_1**: Hey there! What do you mean by the "channel have Assets attached to it?" Are there just entries inside that channel that have assets?  
  > **username_0**: The channel has a "Asset" field type attached to it. The added assets (through this field) have their own fields as well. Thanks.  
  > **username_1**: Ok cool. What are you hoping to return? Entries, assets, or both?  
  > **username_0**: I would like to return entries, but the search would include the searching through the fields for the added assets as well. It not possible I guess I can always run a search() on both entries and assets and combine the result in the template. But would like to avoid it if possible :)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-02-02. Score: 4 | Accepted answer
  
  I gave this a quick test, and it seems that Craft only searches the title field of related assets, when searching entries. What you could do, is first search for all entries with your search term, then all assets with the search term AND related to an entry. Combine those to sets of ids, and you're all set (not really one line of code, though):
  
  ```
  {# your search term #}
  {% set searchTerm = craft.request.param('q') %}
  
  {# first, search all entries with given search term #}
  {% set entries = craft.entries.search(searchTerm).ids() %}
  
  {# first, search all assets with given search term and their relations #}
  {% set assets = craft.assets.search(searchTerm).ids() %}
  {% set entriesRelatedToAssets = craft.entries.relatedTo(assets).ids() %}
  
  {# Combine those ids to one array #}
  {% set allIds = entries | merge(entriesRelatedToAssets) %}
  
  {# Then get all the entries with the given IDs #}
  {% for entry in craft.entries.id(allIds) %}
      {{ entry.title }}<br />
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: This is the idea I had which is totally okay. I guess what I'm trying to do can't really be done with one line of code? Thanks for the code sample!  
  > **username_2**: Someone MIGHT know some `search()` tricks to also search custom fields in related elements. Then it could be done with one line of code. Maybe an email to P&T could give some clarity.  
  > **username_0**: How do you think this code will behave/perform when searching through let's say 100,000 entries? Template overload? :P  
  > **username_2**: Don't know. Using `.ids()` is better (performance-wise) than getting all the objects, but you'd have to test it to be sure.  
  
  ---
  
  