Answers.Body: <p>I think the problem originates from the space in your search term: <code>test ticket</code>.
  To verify that, could you try altering your query to either</p>
  
  <pre><code>.search('"' ~ searchQuery ~ '"')
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>.search('fieldHandle:"' ~ searchQuery ~ '"')
  </code></pre>
  
  <p>The latter can be used if the search has to take place in only one field.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-07T13:25:44.237Z
Answers.Text: That indeed solves the problem. Thank you! Accepted this answer.
Answers.UserDisplayName: mike
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-07T12:14:27.750Z
Answers.LastActivityDate: 2019-03-07T12:14:27.750Z
Answers.UserDisplayName: Paul
Answers.Body: <p>I found out that the problem can be resolved by changing the query from :</p>
  
  <p><code>{% set ticket = craft.entries().search(searchQuery).section('ticketLog').one() %}</code></p>
  
  <p>to</p>
  
  <p><code>{% set ticket = craft.entries().title(searchQuery).section('ticketLog').one() %}</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-07T12:09:42.180Z
Answers.LastActivityDate: 2019-03-07T12:09:42.180Z
Answers.UserDisplayName: mike
Body: <p>In my project I have a <code>tickets</code> which are edited in multiple steps where each step has it's own front end for. Now, of course. to continue editing an ticket I am required to fetch that exact ticket. </p>
  
  <p>To accomplish this I have a search form include which will be displayed before the form is showed. When the search form returns an entry the form is shown, when this fails the search form include will be shown again.</p>
  
  <p>Lastly: The search does work when I search for an entry where the title does not contain a spacebar, So:</p>
  
  <p>When the title is 'Test' I can find it, when the title is <code>test ticket</code> I can't find it using the search form, even though they do both exist!</p>
  
  <p>My code:</p>
  
  <p>General.php settings:</p>
  
  <pre class="lang-php prettyprint-override"><code>'defaultSearchTermOptions' =&gt; [
      'attribute' =&gt; 'title',
      'exact' =&gt; true,
      'subRight' =&gt; false,
      'subLeft' =&gt; false,
  ],
  </code></pre>
  
  <p>My search form:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form novalidate&gt;
      &lt;input id="search" type="search" name="ticket_number"/&gt;
      &lt;button type="submit"&gt;Search&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My <code>URL</code> after submitting the form:</p>
  
  <pre><code>domain.com?ticket_number=ticket+number+test+search
  </code></pre>
  
  <p>My page:</p>
  
  <pre class="lang-php prettyprint-override"><code>{% set searchQuery = craft.app.request.getParam('ticket_number') %}
  {% set ticket = craft.entries().search(searchQuery).section('ticketLog').one() %}
  
  {% if ticket|length %}
      &lt;div class="row"&gt;
          &lt;div class="col-12"&gt;
              &lt;div class="card"&gt;
                  &lt;div class="card-body"&gt;
                      &lt;h4 class="card-title"&gt;Start Picking - {{ ticket.title }}&lt;/h4&gt;
                      &lt;h6 class="card-subtitle"&gt;Fill in this form to start picking.&lt;/h6&gt;
                      {% include '/_components/includes/form' with {
                          'redirect' : siteUrl,
                          'section_handle' : 'ticketLog',
                          'fields' : [{
                              type : 'datetime',
                              handle : 'pickingStartTime',
                          },{
                              type : 'user',
                              title : 'Picker',
                              query : 'teamleader',
                              required : 'required',
                              size : '12',
                          }, {
                              type : 'submit',
                              text : 'Save Ticket',
                          }]
                      } %}
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  {% else %}
      &lt;p&gt;Your search for “{{ searchQuery }}” didn’t return any Tickets, please try again below.&lt;/p&gt;
      {% include 'ticket_log/forms/search_form.twig' %}
  {% endif %}
  </code></pre>
  
  <p>Hope someone sees what I am doing wrong there!</p>
  
Tags: <templating><search>
Title: Search query for entries doesn't seem to work correctly
ThreadText: # Search query for entries doesn't seem to work correctly
  
  (Asked by: username_0 on 2019-03-07)
  
  In my project I have a `tickets` which are edited in multiple steps where each step has it's own front end for. Now, of course. to continue editing an ticket I am required to fetch that exact ticket.
  
  To accomplish this I have a search form include which will be displayed before the form is showed. When the search form returns an entry the form is shown, when this fails the search form include will be shown again.
  
  Lastly: The search does work when I search for an entry where the title does not contain a spacebar, So:
  
  When the title is 'Test' I can find it, when the title is `test ticket` I can't find it using the search form, even though they do both exist!
  
  My code:
  
  General.php settings:
  
  ```php
  'defaultSearchTermOptions' => [
      'attribute' => 'title',
      'exact' => true,
      'subRight' => false,
      'subLeft' => false,
  ],
  
  ```
  
  My search form:
  
  ```html
  <form novalidate>
      <input id="search" type="search" name="ticket_number"/>
      <button type="submit">Search</button>
  </form>
  
  ```
  
  My `URL` after submitting the form:
  
  ```
  domain.com?ticket_number=ticket+number+test+search
  
  ```
  
  My page:
  
  ```php
  {% set searchQuery = craft.app.request.getParam('ticket_number') %}
  {% set ticket = craft.entries().search(searchQuery).section('ticketLog').one() %}
  
  {% if ticket|length %}
      <div class="row">
          <div class="col-12">
              <div class="card">
                  <div class="card-body">
                      <h4 class="card-title">Start Picking - {{ ticket.title }}</h4>
                      <h6 class="card-subtitle">Fill in this form to start picking.</h6>
                      {% include '/_components/includes/form' with {
                          'redirect' : siteUrl,
                          'section_handle' : 'ticketLog',
                          'fields' : [{
                              type : 'datetime',
                              handle : 'pickingStartTime',
                          },{
                              type : 'user',
                              title : 'Picker',
                              query : 'teamleader',
                              required : 'required',
                              size : '12',
                          }, {
                              type : 'submit',
                              text : 'Save Ticket',
                          }]
                      } %}
                  </div>
              </div>
          </div>
      </div>
  
  {% else %}
      <p>Your search for “{{ searchQuery }}” didn’t return any Tickets, please try again below.</p>
      {% include 'ticket_log/forms/search_form.twig' %}
  {% endif %}
  
  ```
  
  Hope someone sees what I am doing wrong there!
  
  **Tags:** templating, search
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-03-07. Score: 1 | Accepted answer
  
  I think the problem originates from the space in your search term: `test ticket`.
  To verify that, could you try altering your query to either
  
  ```
  .search('"' ~ searchQuery ~ '"')
  
  ```
  
  Or
  
  ```
  .search('fieldHandle:"' ~ searchQuery ~ '"')
  
  ```
  
  The latter can be used if the search has to take place in only one field.
  
  > **Comments:**
  > **username_0**: That indeed solves the problem. Thank you! Accepted this answer.  
  
  ---
  
  ### Answer by username_0 on 2019-03-07. Score: 0
  
  I found out that the problem can be resolved by changing the query from :
  
  `{% set ticket = craft.entries().search(searchQuery).section('ticketLog').one() %}`
  
  to
  
  `{% set ticket = craft.entries().title(searchQuery).section('ticketLog').one() %}`
  
  
  ---
  
  