The Equals (EQ) operator works as Contains for text fields when sending GraphQL queries


Description

When requesting an item with a text field using the Equals (EQ) operator, it works as the Contains operator for text fields. The issue is related to the Edge (Preview) schema and that fact that all text fields in the Solr index are tokenized by default.

Solution

To resolve the issue, consider the following steps:

  1. Download and install the cumulative hotfixes for the Experience Edge Connector module that is available in:
    • For Sitecore XP 10.1 and Sitecore Headless Rendering 18: KB1003204
    • For Sitecore XP 10.3 and Sitecore Headless Rendering 21KB1003184
    • For Sitecore XP 10.4 and Sitecore Headless Rendering 22KB1003203
    The core elements of the fix (including assemblies and core configurations) are included in the module package. These updates allow you to map any search field for custom computed fields that do not use the Standard Tokenizer, such as lowercaseString. Nevertheless, additional configuration [1] from step 2 is required to complete the setup.

  2. Perform the setup as follows:
    • In the /App_Config/Sitecore/Services.GraphQL folder, find the example configuration file named Sitecore.Services.GraphQL.EdgeContent.SearchFieldMapping.config.example.
    • Rename this file to Sitecore.Services.GraphQL.EdgeContent.SearchFieldMapping.config.
    • Find the _customname field inside the file, which is the same as _name, but untokenized. This serves as an example for your configuration. To add new fields, follow the same pattern:
      • create new computed fields and add them to the setFieldMapping node in the configuration file.
    • Rebuild the index after making all the changes.
    Be aware that you can still use _name in your search queries. However, it will be internally mapped to _customname.

Note: [1] The mentioned additional setup is also recommended for projects deployed to XM Cloud.