Gravatar for

Question by mark, Jul 29, 2015 12:10 PM

Can CoveoSort component sort on custom fields that are multi value?

Hi, I am using Coveo jsframeworks. I would like to use the CoveoSort component to sort on custom fields. These fields are multi-value fields, so the content items are separated by semi colon. Currently when I try to use the CoveoSort, it returns no results.

Is it possible for CoveoSort component to work on these fields?

Thanks in advance.

1 Reply
Gravatar for

Answer by Luc Bergeron, Jul 29, 2015 2:13 PM


Are you sure your custom fields are marked as sortable? You will see it with the CES Admin Tool (Configuration > Fields).

In my environment, the CoveoSort component works on a multi-value field. It sorts like any other string field, but… unfortunately results are sorted according to the whole string value. It looks weird if you expect that all documents with the value A are returned first, then B, and so on. I think you can work around this limitation by sorting the values in the multi-value field first. There are some different ways to do it and it mostly depends on the index source type.

Here is the CoveoSort I added to my JavaScript search page:

[span class="CoveoSort" data-sort-criteria="@mymultivaluefield ascending,@mymultivaluefield descending"]My Custom Field[/span]

Be careful not to copy and paste the snippet above directly in your web page. I had to replace the angle brackets with square brackets because the custom attributes were not showing in the answer.

I hope this helps

Gravatar for

Comment by mark, Jul 29, 2015 2:21 PM

Hi Ibergeron,

I check to see if the fields were marked as sortable as you suggested and that worked.

thanks for the help.

Ask a question