<p>Just looked at the docs (<a href="https://docs.craftcms.com/v3/searching.html#supported-syntaxes" rel="nofollow noreferrer">https://docs.craftcms.com/v3/searching.html#supported-syntaxes</a>) and it looks like the accepted syntax for this would be:</p>

<p>title::M* OR title:sach</p>

<p>As a result, modifying your code like so should achieve this:</p>

<pre><code>{% set keywordParam = craft.request.param('keyword') %}
{% set characterParam = craft.request.param('filterByCharacter') %}

{% set entriesParams = {
   section: 'people',
   level: 1
} %}

{% set searchArray = [] %}

{% if characterParam|length %}
   {% set searchArray = searchArray|merge(['title::' ~ characterParam ~ '*']) %}
{% endif %}

{% if keywordParam|length %}
   {% set searchArray = searchArray|merge(['title:' ~ keywordParam]) %}
{% endif %}

{% if searchArray|length %}
   {% set searchParam = searchArray|join(' OR ') %}
   {% set entriesParams = entriesParams|merge({ search: searchParam }) %}
{% endif %}

{% set peopleEntries = craft.entries(entriesParams) %}
</code></pre>

<p>Hope that resolves it for you.</p>

CC BY-SA 4.0
2018-12-17T16:43:53.787Z
2018-12-17T16:43:53.787Z
Matt Shearing
<p>I'm trying to filter entries down based on keywords and also if they have selected a letter that matches the first letter of an entry title on Craft 3.</p>

<p>So far I have this:</p>

<pre><code>{% set keywordParam = craft.request.param('keyword') %}
{% set characterParam = craft.request.param('filterByCharacter') %}

{% set entriesParams = {
   section: 'people',
   level: 1
} %}

{% set searchArray = ['OR'] %}

{% if characterParam|length %}
   {% set searchArray = searchArray|merge(['title:' ~ characterParam ~ '*']) %}
{% endif %}

{% if keywordParam|length %}
   {% set searchArray = searchArray|merge(['title:' ~ keywordParam]) %}
{% endif %}

{% if searchArray|length %}
   {% set entriesParams = entriesParams|merge({ search: searchArray }) %}
{% endif %}

{% set peopleEntries = craft.entries(entriesParams) %}
</code></pre>

<p>At the moment this is producing the error:</p>

<blockquote>
  <p>Undefined index: query</p>
</blockquote>

<p>I've narrowed it down to this line(s):</p>

<pre><code>{% if searchArray|length %}
   {% set entriesParams = entriesParams|merge({ search: searchArray }) %}
{% endif %}
</code></pre>

<p>But I can't figure out what is wrong with this, and what could be going wrong!</p>

<p>An example URL is:</p>

<blockquote>
  <p><a href="http://localhost:3000/our-people?keyword=sach&amp;filterByCharacter=M" rel="nofollow noreferrer">http://localhost:3000/our-people?keyword=sach&amp;filterByCharacter=M</a></p>
</blockquote>

<entries><craft3><search>
Using multiple 'search' parameter values to filter entries
# Using multiple 'search' parameter values to filter entries

(Asked by: username_0 on 2018-12-17)

I'm trying to filter entries down based on keywords and also if they have selected a letter that matches the first letter of an entry title on Craft 3.
So far I have this:
{% set keywordParam = craft.request.param('keyword') %}
{% set characterParam = craft.request.param('filterByCharacter') %}

{% set entriesParams = {
   section: 'people',
   level: 1
} %}

{% set searchArray = ['OR'] %}

{% if characterParam|length %}
   {% set searchArray = searchArray|merge(['title:' ~ characterParam ~ '*']) %}
{% endif %}

{% if keywordParam|length %}
   {% set searchArray = searchArray|merge(['title:' ~ keywordParam]) %}
{% endif %}

{% if searchArray|length %}
   {% set entriesParams = entriesParams|merge({ search: searchArray }) %}
{% endif %}

{% set peopleEntries = craft.entries(entriesParams) %}

At the moment this is producing the error:

Undefined index: query

I've narrowed it down to this line(s):
{% if searchArray|length %}
   {% set entriesParams = entriesParams|merge({ search: searchArray }) %}
{% endif %}

But I can't figure out what is wrong with this, and what could be going wrong!
An example URL is:

http://localhost:3000/our-people?keyword=sach&filterByCharacter=M

**Tags:** entries, craft3, search

---

## 1 answers

### Answer by username_1 on 2018-12-17. Score: 3 | Accepted answer

Just looked at the docs (https://docs.craftcms.com/v3/searching.html#supported-syntaxes) and it looks like the accepted syntax for this would be:
title::M* OR title:sach
As a result, modifying your code like so should achieve this:
{% set keywordParam = craft.request.param('keyword') %}
{% set characterParam = craft.request.param('filterByCharacter') %}

{% set entriesParams = {
   section: 'people',
   level: 1
} %}

{% set searchArray = [] %}

{% if characterParam|length %}
   {% set searchArray = searchArray|merge(['title::' ~ characterParam ~ '*']) %}
{% endif %}

{% if keywordParam|length %}
   {% set searchArray = searchArray|merge(['title:' ~ keywordParam]) %}
{% endif %}

{% if searchArray|length %}
   {% set searchParam = searchArray|join(' OR ') %}
   {% set entriesParams = entriesParams|merge({ search: searchParam }) %}
{% endif %}

{% set peopleEntries = craft.entries(entriesParams) %}

Hope that resolves it for you.


---

