index field names
In our index, all of the field names have a suffix of what appears to be a random number. For instance @fdefaulturi12224. That is in one environment. However, in the next environment, that same field is @fdefaulturi81281.
I have three questions:
- Why is that random number appended to the field names?
- Can we remove this suffix altogether?
- If we cannot remove it, how do we make it the same amongst our environments?
I want to be able to pass facets via a query string from a link anywhere on our site, but this suffix is giving us heartburn.
This field suffix number is the hash of the name of the the CES source that uses this field set. It is added by the
CoveoFieldNameTranslatorProcessor processor of the
coveoFieldNameTranslatorPipeline pipeline. The pipeline is used to translate a Sitecore field name to its equivalent name in the Coveo index (e.g. Title becomes @ftitle87624, where '87624' is a hash value computed from the name of the Coveo source corresponding to the current search index).
This hash is mandatory because Coveo for Sitecore creates one CES field set per Sitecore index and many Sitecore instances can be indexed in the same CES index. CES does not support to have the same field in 2 field sets with different types or options (facet, multi-value facet, sortable, free-text search…). If a field is different in 2 Sitecore indexes, databases or instances, the source hash suffix will do the job to keep the fields independent in the CES index.
In a Sitecore farm with scaling across many CM and CD servers, Coveo scaling guide recommends to set the
<SourceName> node of the Sitecore indexes to the same values (e.g.:
<SourceName>Sitecore Farm X - Master</SourceName> for the master index and
<SourceName>Sitecore Farm X - Web</SourceName> for the web index). (see "Configuring Coveo for Sitecore" section of Scaling Coveo for Sitecore Over Multiple Servers).
You shouldn't use the same source names across unrelated Sitecore farms to avoid field collisions.
In a Sitecore farm, you should follow all the suggestions of the Coveo scaling guide. Specifically the
You can decide to remove this suffix for specific fields by adding the fields to the
<fieldMap><fieldNames> node with the
isExternal="true" attribute (see "Step 3" of Displaying External Content in a Search Interface).
Another solution for you would be to send the Sitecore field name and to use the
ToCoveoFieldName helper method in your destination application. It accepts a Sitecore field name and an optional second parameter to indicate whether to prefix the Coveo field name with "@" or not. The method is available on multiple classes depending on where you need to use it in the code. Some versions accept an IIndexable object used to resolve the database to use for the translation. The method is primarily used in the sublayouts and views to get the field names for the current Sitecore context database and index.