Multivalued facet with a lookup field does not work if there is > 1 value
Hello - I have a data template with a "Multilist" field. The field is used to tag 1 or more terms from another list. (eg. "Tag 1", "Tag 2", "Tag 3" etc.
I have created several occurrences of this data template and tagged each one with either 1 or multiple tag values.
I added a foreign key definition to the Coveo.SearchProvider.config.xml file to look up the value of the tag id in the Tag list and return the "TagTitle" property like this:
<ForeignKeysConfiguration type="Coveo.Framework.Configuration.ForeignKeys.ForeignKeysConfiguration, Coveo.Framework"> <foreignKeys hint="list:AddForeignKey"> <foreignKey type="Coveo.Framework.Configuration.ForeignKeys.ForeignKeyConfiguration, Coveo.Framework"> <keyInfo type="Coveo.Framework.Configuration.ForeignKeys.KeyInfo, Coveo.Framework"> <templateName>News Release Template</templateName> <fieldName>NewsReleaseTags</fieldName> </keyInfo> <valueInfo type="Coveo.Framework.Configuration.ForeignKeys.ValueInfo, Coveo.Framework"> <templateName>News Release Tag</templateName> <correspondingKeyFieldName>id</correspondingKeyFieldName> <fieldName>TagTitle</fieldName> </valueInfo> </foreignKey> </foreignKeys> </ForeignKeysConfiguration>
I then rebuilt the master and web indexes.
Then I added a facet in System -> Settings -> Buckets -> Facets defined on the NewsReleaseTags field, published it, and rebuilt the indexes again.
I then added a regular facet component to the search results page. I indicated "multivalue", and added a lookup template of "News Release Template" and field of "News Release Tags".
The facet values render properly when there is only 1 value, but for > 1 tag, the facet displays the guids concatenated together.
Using the CES Admin tool, I looked at the indexed documents in the master and web indexes. I can see that the indexer has set the "fnewsreleasetags99999" field to the original value (either 1 or multiple). It has also added a new field "ftagtitle99999" to the documents, but ONLY when the document has 1 value in the News Release Tags field. For documents which have > 1 value in the News Release Tags field, the "ftagtitle99999" field was NOT added to the indexed document.
I think that what is missing is that when I defined the field as a facet, the search provider did not update the index to mark the new facet field as multi-valued (the checkbox in the CES Admin Tool is unchecked).
Should this be marked as a multi-valued facet? If so, is there a manual way that I can update the facet definition?
We highly suggest that you use Computed Fields instead of Foreign Keys, just like stated in this page :
Hi Vincent -- yay, that worked! To confirm, I added 2 entries in the Coveo.SearchProvider.config.xml file:
Under the fieldMap/fieldNames node, I added:
<fieldType fieldName='newsreleasetagtitle' isFacet="true" isMultiValue="true" settingType='Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework' />
And under the fieldMap/fields node, I added:
<field fieldName="newsreleasetagtitle" sourceField="newsreleasetags" referencedFieldName="tagtitle">Coveo.SearchProvider.ComputedFields.ReferencedFieldComputedField, Coveo.SearchProviderBase</field>
Thanks for your help!