Configure partial search

Current version: 10.3

Applies to

Apache Solr.

Sitecore xConnect Search supports partial text search using the Apache Solr Edge N-Gram Tokenizer. An edge n-gram of the single word Sitecore with a minimum value of 2 and a maximum value of 4 produces the tokens Si, Sit, and Site. A similar edge n-gram of the two-word string xConnect Search produces the tokens xC, xCo, xCon and Se, Sea, Sear.

Important

You modify a Solr schema by sending a POST request containing a block of JSON formatted commands to the https://<Apache Solr>/collection/schema/ endpoint of both the active and the rebuild versions of the Solr core. They are named <core_name> and <core_name>_rebuild.

Add a partial text search field

The xConnect Search role comes preconfigured with partial search activated for the following Personal Information facet fields personal.firstname, personal.middlename, personal.lastname, and emails.preferredemail.smtpaddress.

To add a partial text search field:

  1. Post the <xConnect Search role>\App_data\solrcommands\10.0-or-later-schema-preparation.json file to both Solr cores. You might get a 404 error, which is normal.

  2. Open the <xConnect Search role>\App_Data\solrcommands\schema.json file.

  3. Add a new add-copy-field command where the preconfigured fields are located. The source property must be the field that you want to activate partial search for, and the dest property must always be textmatch.

    RequestResponse
    "add-copy-field": [{
      "source": "facets.personal.firstname_s",
      "dest": "textmatch"
    }]
    

    The add-copy-field section aggregates the necessary variations (edge n-gram tokens) of the source data into the textmatch field.

  4. To avoid issues that can prevent later modifications of the Solr schema, add the facets.personal.firstname_s field to the add-field section:

    RequestResponse
    "add-field": [{
      "name": "facets.personal.firstname_s ",
      "type": "lowercase",
      "stored": false,
      "indexed": true,
      "omitNorms": true
    }]
  5. Save the schema.json file.

  6. Post the schema.json file to both Solr cores.

Modify an existing partial text search field

If you need to modify an existing partial text search field, you must first delete its original configuration.

To modify a partial text search field:

  1. Post the <xConnect Search role>\App_data\solrcommands\10.0-or-later-schema-preparation.json file to both Solr cores. You might get a 404 error, which is normal.

  2. Open the <xConnect Search role>\App_Data\solrcommands\schema.json file.

  3. Before the add-copy-field command that modifies your partial text search field, insert a command to delete the original configuration:

    RequestResponse
    "delete-copy-field": [{
      "source":"facets.personal.firstname_s",
      "dest":"textmatch"
    }]
    "delete-field": [{ "name": "facets.personal.firstname_s" }]
  4. Save the schema.json file.

  5. Post the schema.json file to both Solr cores.

The textmatch field is configured to be a multi valued text_match field type. See the add-field section of the schema.json file for the specific details.

You can optimize partial search in the filters section of the text_match field type configuration. The default values set the minimum n-gram size to 2 and the maximum size to 15. The higher the range between the two numbers, the more index space is required.

To optimize partial text search:

  1. Post the <xConnect Search role>\App_data\solrcommands\10.0-or-later-schema-preparation.json file to both Solr cores. You might get a 404 error, which is normal.

  2. Open the <xConnect Search role>\App_Data\solrcommands\schema.json file.

  3. Change the minGramSize and maxGramSize properties to your preferred values:

    RequestResponse
    "filters": [
      { "class": "solr.LowerCaseFilterFactory" },
      {
        "class": "solr.EdgeNGramFilterFactory",
        "minGramSize": "2",
        "maxGramSize": "15",
        "preserveOriginal": "true"
      }
    ]
  4. Save the schema.json file.

  5. Post the schema.json file to both Solr cores.

If you have no need for partial search, you can disable it and improve performance.

To disable partial text search:

  1. Post the <xConnect Search role>\App_data\solrcommands\10.0-or-later-schema-preparation.json file to both Solr cores. You might get a 404 error, which is normal.

  2. Open the <xConnect Search role>\App_Data\solrcommands\schema.json file.

  3. Delete the preconfigured add-copy-field section from the schema.json file:

    RequestResponse
    "add-copy-field": [
      {
        "source": "facets.personal.firstname_s",
        "dest": "textmatch"
      },
      {
        "source": "facets.personal.middlename_s",
        "dest": "textmatch"
      },
      {
        "source": "facets.personal.lastname_s",
        "dest": "textmatch"
      },
      {
        "source": "facets.emails.preferredemail.smtpaddress_s",
        "dest": "textmatch"
      }
    ]
  4. Save the schema.json file.

  5. Post the schema.json file to both Solr cores.

Do you have some feedback for us?

If you have suggestions for improving this article,