Answers.Body: <blockquote>
    <p>Is there a way for search to return a result that is only a partial match to the query to take into account slight differences between the query and a page title?</p>
  </blockquote>
  
  <p>Not natively.</p>
  
  <p>When you put a title of "ABC-123" into a title in Craft, it will normalize it down to " abc 123 " when putting it into the <code>craft_searchindex</code> table (lowercasing all letter and removing punctuation).  And Craft does a similar thing for searches (lowercases them and removes punctuation).</p>
  
  <p>With <code>subLeft</code> and <code>subRight</code> enabled, searching for <code>ABC</code> turns it into a MySQL fulltext search with wildcards on the left and right... i.e. <code>LIKE '%abc%'</code> so it will match what's in the <code>search_index</code> table.</p>
  
  <p>Likewise <code>ABC-123</code> gets converted to <code>%abc 123%</code>, which will match, <code>ABC 123</code> also gets converted to <code>%abc 123%</code>, which will match and <code>123</code> into <code>%123%</code> which will match.</p>
  
  <p><code>ABC123</code> would get converted to <code>%abc123%</code> which wouldn't match (nor would <code>ABB-123</code>.</p>
  
  <p>MySQL does have a <a href="https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_soundex" rel="nofollow noreferrer">SOUNDEX()</a> method, which might do what you're looking for, but it does have enough drawbacks that Craft wouldn't use it natively.</p>
  
  <p>i.e. it won't work against full text indexes, inconsistent results in non-English languages and inconsistent results with multi-byte characters (even if they are UTF-8).</p>
  
  <p>Some other search services might offer more robust solutions (Algolia, Apache Lucere, etc.) that you could wrap with a plugin for searches on the front-end of a Craft site, but you should add a thumbs-up comment to this <a href="https://github.com/craftcms/cms/issues/833" rel="nofollow noreferrer">Github issue</a> if you'd like the ability for plugins to swap out the core search provider that Craft uses wholesale (including for the Control Panel).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-15T08:31:55.877Z
Answers.Text: Thanks for the help Brad. Your feedback confirmed what I had been thinking about the limitations of what we should expect to be able to do with the built-in search
Answers.UserDisplayName: Steve Rowland
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-01T21:38:59.830Z
Answers.LastActivityDate: 2017-06-01T21:38:59.830Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have entry titles that contain dashes (i.e. ABC-123). When I search for 'ABC', 'ABC-123', 'ABC 123', '123' etc the entry is shown in the results (I have fuzzy search enabled). However, when I search for 'ABC123' or anything with the dash omitted from the query the entry does not appear in the results. The same goes for misspellings (i.e. 'ABB-123').</p>
  
  <p>Is there a way for search to return a result that is only a partial match to the query to take into account slight differences between the query and a page title?</p>
  
  <p>Please note that I have the following fuzzy search config settings:</p>
  
  <pre><code>'defaultSearchTermOptions' =&gt; array(
      'subLeft' =&gt; true,
      'subRight' =&gt; true,
  ),
  </code></pre>
  
  <p>And I have the following search query template code:</p>
  
  <pre><code>{% set query = craft.request.getParam('q')|replace('/(( )+|(\\n)+)/', ' ')|split(' ')|join(' OR ') %}
  </code></pre>
  
Tags: <search><query>
Title: Search results with partial match to query
ThreadText: # Search results with partial match to query
  
  (Asked by: username_0 on 2017-06-01)
  
  I have entry titles that contain dashes (i.e. ABC-123). When I search for 'ABC', 'ABC-123', 'ABC 123', '123' etc the entry is shown in the results (I have fuzzy search enabled). However, when I search for 'ABC123' or anything with the dash omitted from the query the entry does not appear in the results. The same goes for misspellings (i.e. 'ABB-123').
  
  Is there a way for search to return a result that is only a partial match to the query to take into account slight differences between the query and a page title?
  
  Please note that I have the following fuzzy search config settings:
  
  ```
  'defaultSearchTermOptions' => array(
      'subLeft' => true,
      'subRight' => true,
  ),
  
  ```
  
  And I have the following search query template code:
  
  ```
  {% set query = craft.request.getParam('q')|replace('/(( )+|(\\n)+)/', ' ')|split(' ')|join(' OR ') %}
  
  ```
  
  **Tags:** search, query
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-01. Score: 1 | Accepted answer
  
  > Is there a way for search to return a result that is only a partial match to the query to take into account slight differences between the query and a page title?
  
  Not natively.
  
  When you put a title of "ABC-123" into a title in Craft, it will normalize it down to " abc 123 " when putting it into the `craft_searchindex` table (lowercasing all letter and removing punctuation). And Craft does a similar thing for searches (lowercases them and removes punctuation).
  
  With `subLeft` and `subRight` enabled, searching for `ABC` turns it into a MySQL fulltext search with wildcards on the left and right... i.e. `LIKE '%abc%'` so it will match what's in the `search_index` table.
  
  Likewise `ABC-123` gets converted to `%abc 123%`, which will match, `ABC 123` also gets converted to `%abc 123%`, which will match and `123` into `%123%` which will match.
  
  `ABC123` would get converted to `%abc123%` which wouldn't match (nor would `ABB-123`.
  
  MySQL does have a [SOUNDEX()](https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_soundex) method, which might do what you're looking for, but it does have enough drawbacks that Craft wouldn't use it natively.
  
  i.e. it won't work against full text indexes, inconsistent results in non-English languages and inconsistent results with multi-byte characters (even if they are UTF-8).
  
  Some other search services might offer more robust solutions (Algolia, Apache Lucere, etc.) that you could wrap with a plugin for searches on the front-end of a Craft site, but you should add a thumbs-up comment to this [Github issue](https://github.com/craftcms/cms/issues/833) if you'd like the ability for plugins to swap out the core search provider that Craft uses wholesale (including for the Control Panel).
  
  > **Comments:**
  > **username_0**: Thanks for the help username_1. Your feedback confirmed what I had been thinking about the limitations of what we should expect to be able to do with the built-in search  
  
  ---
  
  