Configure partial search
|
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.
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:
-
Post the
<xConnect Search role>\App_data\solrcommands\10.0-or-later-schema-preparation.jsonfile to both Solr cores. You might get a 404 error, which is normal. -
Open the
<xConnect Search role>\App_Data\solrcommands\schema.jsonfile. -
Add a new
add-copy-fieldcommand where the preconfigured fields are located. Thesourceproperty must be the field that you want to activate partial search for, and thedestproperty must always betextmatch.RequestResponse"add-copy-field": [{ "source": "facets.personal.firstname_s", "dest": "textmatch" }]The
add-copy-fieldsection aggregates the necessary variations (edge n-gram tokens) of the source data into thetextmatchfield. -
To avoid issues that can prevent later modifications of the Solr schema, add the
facets.personal.firstname_sfield to theadd-fieldsection:RequestResponse"add-field": [{ "name": "facets.personal.firstname_s ", "type": "lowercase", "stored": false, "indexed": true, "omitNorms": true }] -
Save the
schema.jsonfile. -
Post the
schema.jsonfile 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:
-
Post the
<xConnect Search role>\App_data\solrcommands\10.0-or-later-schema-preparation.jsonfile to both Solr cores. You might get a 404 error, which is normal. -
Open the
<xConnect Search role>\App_Data\solrcommands\schema.jsonfile. -
Before the
add-copy-fieldcommand 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" }] -
Save the
schema.jsonfile. -
Post the
schema.jsonfile to both Solr cores.
Optimize partial text search
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:
-
Post the
<xConnect Search role>\App_data\solrcommands\10.0-or-later-schema-preparation.jsonfile to both Solr cores. You might get a 404 error, which is normal. -
Open the
<xConnect Search role>\App_Data\solrcommands\schema.jsonfile. -
Change the
minGramSizeandmaxGramSizeproperties to your preferred values:RequestResponse"filters": [ { "class": "solr.LowerCaseFilterFactory" }, { "class": "solr.EdgeNGramFilterFactory", "minGramSize": "2", "maxGramSize": "15", "preserveOriginal": "true" } ] -
Save the
schema.jsonfile. -
Post the
schema.jsonfile to both Solr cores.
Disable partial text search
If you have no need for partial search, you can disable it and improve performance.
To disable partial text search:
-
Post the
<xConnect Search role>\App_data\solrcommands\10.0-or-later-schema-preparation.jsonfile to both Solr cores. You might get a 404 error, which is normal. -
Open the
<xConnect Search role>\App_Data\solrcommands\schema.jsonfile. -
Delete the preconfigured
add-copy-fieldsection from theschema.jsonfile: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" } ] -
Save the
schema.jsonfile. -
Post the
schema.jsonfile to both Solr cores.