Using External Content in Sitecore Facets
Using External Content in Sitecore Facets
This page assumes that you’ve already indexed an external source in the Coveo Enterprise Search (CES) Administration Tool, and have enabled that source as searchable in your Sitecore instance. For more information, on how to do this, see Configuring an External Source and Enabling the External Source in Sitecore.
This page assumes that you’ve already indexed an external source in the Coveo Platform, and have enabled that source as searchable in your Sitecore instance. For more information on how to do this, see Configuring an External Source and Enabling the External Source in Sitecore.
Now that you’ve indexed external content into Sitecore, you probably want to filter it using facets too. For this example, you’ll want to filter items by author.
-
In the Experience Editor, add a Coveo Facet.
-
Title: Enter
Author
. -
Field: Select
Author
.
-
-
Click OK to add the facet.
You’ll notice that only your Sitecore items are shown in the facet. That’s because your external content doesn’t contain the Author
facet.
Sitecore already has a facet called Author, which you can find under Sitecore > System > Settings > Buckets > Facets.
If you click the Author facet, under Field Name, you can see that it’s created from the field parsedcreatedby
. This is the field that you need to add to your external sources to have them appear in your Author facet.
Step 1: Verify That the Field Doesn’t Already Exist in Your Sources
To prevent overwriting an existing field, you need to verify if it already exists in your sources.
-
In the CES Administration Console, go to Content > Index Browser.
-
Choose one of your external items, and click Details.
-
Under the Fields tab, validate that the field
parsedcreatedby
doesn’t exist.
-
In the Administration Console, go to Content > Content Browser.
-
Choose one of your external items, and click Properties.
-
Under Fields, verify that there are no field called
parsedcreatedby
.
Step 2: Adding the Field Name to Your External Content
You now need to add the field parsedcreatedby
to your external content, and set it to the author of your external source.
-
Under Index > Sources and Collections, click your external source.
-
In the menu on the left, select Fields.
-
Click Edit, bringing you to the Configuration > Fields > Custom Fields page of your external source.
-
Click Add, and enter the following parameters:
-
Name: Enter a name for your custom field. For this example, use
parsedcreatedby
. -
Type: Keep it at String.
-
Metadata Name: Enter the name of your field. For this example, use
parsedcreatedby
. -
Default Value: Enter the value given to your field. For this example, use
Sitecore website
. -
Option: Make sure
Allow faceted search on this field
is checked. -
Click Apply Changes.
-
-
Rebuild your source. Under Index > Sources and Collections, select your source, and choose Rebuild.
-
After the source has finished rebuilding, verify that your field was applied to your source.
-
Under Content > Index Browser, choose one of your items, and click Details.
-
Choose the Fields tab. Your new field should appear.
-
-
In the Administration Console, select Content > Sources.
-
Select your source, and then click Mappings in the Action bar.
-
Click Add Mapping, and format your mapping this way:
-
Apply to: Choose All item types.
-
Field name: Choose
parsedcreatedby
. -
Extraction method: Choose Literal string.
-
Content: Type in the name of the author of your external content.
-
-
Click Apply, and then on Save and Rebuild.
-
After the source has finished rebuilding, verify that your field was applied to your source.
-
Go to the Content Browser.
-
Access your item properties by clicking Properties. When searching for your field, you should now get a result with the right value.
-
Step 3: Tell Sitecore to Consider the Field as a Facet
Now that you’ve added the field parsedcreatedby
to your external items, you need to have it recognized in your Sitecore instance.
By default, Coveo for Sitecore hashes field names, adding an f
before its name and up to five digits at the end, resulting in something similar to fadministrator69462
. This is done to avoid field name collisions.
For this example, you want to avoid having your field name hashed. This is how to do it.
-
Open your
Coveo.SearchProvider.Custom.config
file. It’s usually located under<SITECORE_INSTANCE_ROOT>\Website\App_Config\Include\Coveo
. -
In the
defaultIndexConfiguration
element, add the following nodes. By configuring the fieldparsedcreatedby
as external, you’re preventing it from being hashed.
```xml
<fieldMap>
<fieldNames>
<fieldType fieldName="parsedcreatedby" isExternal="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />
</fieldNames>
</fieldMap>
```
```xml
<fieldMap>
<fieldNames>
<fieldType fieldName="parsedcreatedby" isSourceSpecific="false" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />
</fieldNames>
</fieldMap>
```
-
Save and close the file.
-
Rebuild your Sitecore indexes.
-
When you refresh your search page, validate that
Sitecore website
appears as an author in the Author facet.