<p>It doesn't look like it's possible to pass an array of attributes to the <code>attribute</code> parameter, the Craft docs explicitly state that it expects a string.</p>

<p><a href="https://craftcms.com/docs/config-settings#defaultSearchTermOptions" rel="nofollow">https://craftcms.com/docs/config-settings#defaultSearchTermOptions</a></p>

CC BY-SA 3.0
2016-02-10T00:27:37.643Z
2016-02-10T16:50:07.523Z
2016-02-10T16:50:07.523Z
carlcs
<p>Think it should be:</p>

<pre><code>search: {
  attribute: {
    'keywords', 
    'body', 
    'title'
  }
},
</code></pre>

CC BY-SA 3.0
2016-02-09T21:15:36.047Z
Unfortunately, no. That returns the same error. There are other key/value pairs.
Bud Parr
CC BY-SA 3.0
2016-02-09T21:03:19.930Z
2016-02-09T21:03:19.930Z
Dave Driesmans
<p><em>Craft Pro 2.5.2761 (no plugins)</em></p>

<p>I've got a basic search form, and on my results template, the following:</p>

<pre><code>{% set query = craft.request.getParam('q') %}

{% set articles = craft.entries({
section: 'article',
order: 'score',
search: {
  attribute: 'keywords',
  query: query,
  subLeft: true,
  subRight: true
}
}) %}
</code></pre>

<p>Which works as expected (I get results when the query term matches the keyword of an entry). </p>

<p>However, I want my search to encompass not just keywords, but also the  title and the body field. </p>

<p>[edit - deleted part of my post because it was misleading as to the real problem]</p>

CC BY-SA 3.0
2016-02-10T00:30:31.547Z
You're using the object syntax, which expects key-value pairs `{% set var = {'key1': 'value1', 'key2': 'value2'} %}`. Try this to set an array `{% set var = ['value1', 'value2'] %}`, but I don't actually expect this to work. See my answer below.
carlcs
CC BY-SA 3.0
2016-02-10T05:01:16.410Z
You're right, on both counts. I had tried that (only posted the last thing I tried, in desperation), and it didn't work, as you thought.
Bud Parr
CC BY-SA 3.0
2016-02-10T17:09:54.370Z
Now that you modified your question, it's probably a dupe of the one I linked to above. I hope you find the new answer I just posted to it helpful.
carlcs
<search>
Set Search to query multiple attributes (e.g. title, body)
# Set Search to query multiple attributes (e.g. title, body)

(Asked by: username_0 on 2016-02-09)

Craft Pro 2.5.2761 (no plugins)
I've got a basic search form, and on my results template, the following:
{% set query = craft.request.getParam('q') %}

{% set articles = craft.entries({
section: 'article',
order: 'score',
search: {
  attribute: 'keywords',
  query: query,
  subLeft: true,
  subRight: true
}
}) %}

Which works as expected (I get results when the query term matches the keyword of an entry). 
However, I want my search to encompass not just keywords, but also the  title and the body field. 
[edit - deleted part of my post because it was misleading as to the real problem]

**Tags:** search

> **Comments:**
> **username_1**: You're using the object syntax, which expects key-value pairs `{% set var = {'key1': 'value1', 'key2': 'value2'} %}`. Try this to set an array `{% set var = ['value1', 'value2'] %}`, but I don't actually expect this to work. See my answer below.  
> **username_0**: You're right, on both counts. I had tried that (only posted the last thing I tried, in desperation), and it didn't work, as you thought.  
> **username_1**: Now that you modified your question, it's probably a dupe of the one I linked to above. I hope you find the new answer I just posted to it helpful.  

---

## 2 answers

### Answer by username_1 on 2016-02-10. Score: 2

It doesn't look like it's possible to pass an array of attributes to the `attribute` parameter, the Craft docs explicitly state that it expects a string.

<https://craftcms.com/docs/config-settings#defaultSearchTermOptions>


---

### Answer by username_2 on 2016-02-09. Score: 0

Think it should be:
search: {
  attribute: {
    'keywords', 
    'body', 
    'title'
  }
},

> **Comments:**
> **username_0**: Unfortunately, no. That returns the same error. There are other key/value pairs.  

---

