Gravatar for changping.peng@avanade.com

Question by helen, Feb 22, 2016 12:49 PM

How to sort by publishing date ?

Hi team,

I have a question about sortCriteria parameter. How to sort by PublishDate or any field with DateTime field type in sitecore ? I tried the code below but no luck. args.queryBuilder.sortCriteria = "@(Model.ToCoveoFieldName("PublishDate", false)) descending";

Your suggestion would be much appreciated.

Regards, Helen

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Feb 22, 2016 7:07 PM

Hi Helen,

Did you make sure your Sitecore "PublishedDate" field has the isSortable="true" option in the field map before trying to sort on it (see Making a Sitecore field sortable)?

Try to set the option even if the documentation says date fields should be sortable by default and tell me if it helps.

Thank you,

Jeff

Gravatar for changping.peng@avanade.com

Comment by helen, Feb 23, 2016 2:02 PM

Hi Jeff,

Thanks!

For some reason, it does not work for me. I added the code in Coveo.SearchProvider.config and rebuilt index.

<fieldType fieldName="Updated" isSortable="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />

Query:

args.queryBuilder.sortCriteria = "@(Model.ToCoveoFieldName("Updated")) descending";

How do I know if indexed field <Update> is for the Sitecore statistic field < __updated>? I also tried the config below but no luck.

<fieldType fieldName="__publish" isSortable="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />
<fieldType fieldName="__updated" isSortable="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />

Regards,

Helen

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 23, 2016 5:48 PM

The Sitecore statistics field __updated can be referred to by using @(Model.ToCoveoFieldName("__Updated")) in your code. It is indexed as fz95xz95xupdatedXXXXX in the search index.

Gravatar for changping.peng@avanade.com

Comment by helen, Feb 23, 2016 9:04 PM

HI Jeff,

It works with "__Updated". Thanks a lot!

Just try to dig little bit more about the fields. I can find 3 fields for update which caused my confusion previously. Could you please help clarify them?

  1. @fz95xz95xupdatedz32xby659 - __Updated
  2. @fparsedupdatedby659 - _updated
  3. @fz95xupdated659 - Update

Regards, Helen

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 24, 2016 1:38 AM

Hi Helen,

I think you mixed some "updated" with "updated by" fields in your listing. Is it the case?

In your Coveo Enterprise Search field set (Administration Tool > Configuration > Fields) for any of your Sitecore index, you can have the list of fields and their "metadata name" (the name of their related Sitecore fields).

In my case I have:

  • fparsedupdatedby46930: parsedupdatedby (Name of the Sitecore user that last updated the item. Without slash character between domain and username for easy comparison. Sitecore computed index field used by Sitecore when Coveo replaces the Lucene indexes)
  • fupdated46930: Updated (Last item update date. Coveo field on all items)
  • fupdatedby46930: UpdatedBy (Name of the Sitecore user that last updated the item. Coveo field on all items.)
  • fz95xupdated46930: _updated (Last item update date. Sitecore system field on all items. I don't see any difference with __Updated.)
  • fz95xz95xsmallupdateddate46930: __smallupdateddate (Last item update date. Sitecore system field on all items. I don't see any difference with __Updated.)
  • fz95xz95xupdated46930: __Updated (Last item update date. Sitecore system field on all items)
  • fz95xz95xupdatedz32xby46930: __Updated by (Name of the Sitecore user that last updated the item. Sitecore system field on all items.)

Coveo creates a copy of many Sitecore system fields like "__updated" and "__updated by". This can be disabled by setting the IndexCoveoFields setting to false in your Coveo.SearchProvider.config file (see Understanding the Coveo Search Provider's Configuration File).

I hope this helps you.

Jeff

Ask a question