Answers.Body: <p>The reason it's happening:</p>
  
  <p>When Craft's <a href="https://craftcms.com/classreference/services/SearchService" rel="nofollow noreferrer">SearchService</a> indexes the keywords for a field, they go though a <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/services/SearchService.php#L302" rel="nofollow noreferrer">normalization</a> process that specifically removes <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/helpers/StringHelper.php#L365" rel="nofollow noreferrer">punctuation and diacritics</a> before being saved to the <code>craft_searchindex</code> table in the database.</p>
  
  <p>In the case of numeric values, that's going to include things like decimals, grouping separators and negation symbols.</p>
  
  <p>A workaround if you're doing this on a front-end search form, is to query the field's value directly, bypassing the SearchService. So...</p>
  
  <pre><code>{% set results = craft.entries.fieldName('-2').find() %}
  </code></pre>
  
  <p>Which is going to try and do a direct match against that field's actual value in the <code>craft_content</code> table.</p>
  
  <p>There are a few feature requests you might want to add your voice to that would make your situation better as well:</p>
  
  <p><a href="https://github.com/craftcms/cms/issues/1630" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/1630</a></p>
  
  <p><a href="https://github.com/craftcms/cms/issues/833" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/833</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-14T16:38:11.853Z
Answers.Text: Gotcha. Unfortunately I need this in the control panel entries list. I'll add a comment to that FR.
Answers.UserDisplayName: Eli Van Zoeren
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-13T22:06:51.083Z
Answers.LastActivityDate: 2017-11-13T22:06:51.083Z
Answers.UserDisplayName: Brad Bell
Body: <p>I discovered today that searching a custom field for a number will return results containing either the positive or negative versions of the number, even if I do an exact search. For example: <code>fieldName::"-2"</code> will give me entries where that field contains either "2" or "-2". Same result if I search for <code>fieldName::"2"</code>. The field in question is a "number" field.</p>
  
  <p>Is there any workaround for this?</p>
  
Tags: <control-panel><search>
Title: How to differentiate between positive and negative numbers in search
ThreadText: # How to differentiate between positive and negative numbers in search
  
  (Asked by: username_0 on 2017-11-13)
  
  I discovered today that searching a custom field for a number will return results containing either the positive or negative versions of the number, even if I do an exact search. For example: `fieldName::"-2"` will give me entries where that field contains either "2" or "-2". Same result if I search for `fieldName::"2"`. The field in question is a "number" field.
  
  Is there any workaround for this?
  
  **Tags:** control-panel, search
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-13. Score: 0 | Accepted answer
  
  The reason it's happening:
  
  When Craft's [SearchService](https://craftcms.com/classreference/services/SearchService) indexes the keywords for a field, they go though a [normalization](https://github.com/pixelandtonic/Craft-Release/blob/master/app/services/SearchService.php#L302) process that specifically removes [punctuation and diacritics](https://github.com/pixelandtonic/Craft-Release/blob/master/app/helpers/StringHelper.php#L365) before being saved to the `craft_searchindex` table in the database.
  
  In the case of numeric values, that's going to include things like decimals, grouping separators and negation symbols.
  
  A workaround if you're doing this on a front-end search form, is to query the field's value directly, bypassing the SearchService. So...
  
  ```
  {% set results = craft.entries.fieldName('-2').find() %}
  
  ```
  
  Which is going to try and do a direct match against that field's actual value in the `craft_content` table.
  
  There are a few feature requests you might want to add your voice to that would make your situation better as well:
  
  <https://github.com/craftcms/cms/issues/1630>
  
  <https://github.com/craftcms/cms/issues/833>
  
  > **Comments:**
  > **username_0**: Gotcha. Unfortunately I need this in the control panel entries list. I'll add a comment to that FR.  
  
  ---
  
  