Gravatar for

Question by dwebb, Dec 5, 2014 12:18 AM

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>
            <valueInfo type="Coveo.Framework.Configuration.ForeignKeys.ValueInfo, Coveo.Framework">
                <templateName>News Release Tag</templateName>

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?

Cheers David

Gravatar for

Comment by dwebb, Dec 5, 2014 1:21 AM

Oops, slight mistake above. The "ftagtitle99999" does not appear in the master or web indexes as a field in the documents. But if I execute a query against the database for a document that has a single value in its News Release Tag field, then the JSON data returned includes both the fnewsreleasetags9999 and the ftagtitle9999 fields. If I search for a document with multiple values in the fnewsreleasetags9999 field, then the fnewsreleasetags9999field is returned, but the ftagtitle9999 is NOT returned at all. So t may be a bug in the query processing, not in the indexing.


2 Replies
Gravatar for

Answer by Vincent Séguin, Dec 5, 2014 8:15 AM

Hi David,

We highly suggest that you use Computed Fields instead of Foreign Keys, just like stated in this page :

Thank you!

Gravatar for

Comment by dwebb, Dec 5, 2014 11:25 AM

Hi Vincent - ok, I did that, and it's better, but still not what I want. The values of the tags are all shown properly now, instead of GUIDs, so that's good. However, it still doesn't break the multi-values apart -- it looks like this:

Tag 1; Tag 2; Tag 3 (5)
Tag 1; Tag 3 (3)
Tag 1 (2)
Tag 2; Tag 4 (5)

I want each tag to be shown individually with the total count of documents that reference it -- using the example above, I want it to be

Tag 1 (10)
Tag 2 (10)
Tag 3 (8)
Tag 4 (5)

I have checked the "is multi-valued" checkbox on the Facet rendering.

Thanks, David

Gravatar for

Comment by Vincent Séguin, Dec 5, 2014 11:41 AM

Hi David,

Did you put your field as 'multiValue' in the field map of your Coveo.SearchProvider.config? If you put isMultiValue="true" and then reindex your items, it will do the change in CES automatically.

You can learn more about it on this page :'s+Configuration+File in the field map section.

Thank you, Vincent

Gravatar for

Answer by dwebb, Dec 5, 2014 1:51 PM

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!

Ask a question