Gravatar for

Question by DEEPTHI KATTA, Dec 29, 2016 10:50 PM

Sort on Default Sort Option not working

I am using the Tab component Default Sort Order options to pick -

  • Type as "Field"
  • Order as say "Ascending"
  • Picked a field that is number - "Like say Number of Bedrooms" for example

It does not work - It still seems to be relevance and no effect on ordering

Now, if I use something like

  • Type as "Date"
  • Oder say "Descending"
  • Field - __Updated

It seems working

Do we need to add and do specific steps for sort ordering picked on Default Sort Options to work.

I do see sort being appended to URL params correctly though. I am unsure if I am missing any step or something.

Gravatar for

Comment by DEEPTHI KATTA, Dec 29, 2016 10:56 PM

It seems like there is a delay. Could be indexing updates on the background. :) Does this seem correct. Is this the behavior gonna be? Do confirm regardless if I am missing something

2 Replies
Gravatar for

Answer by Sébastien Belzile, Dec 30, 2016 10:48 AM

This is a known issue that has been recently noticed and is fixed in the January 17 release. The bug was introduced in June 16 (by myself :-( ).

If you need a default sort by field with one of the versions affected, you can use the GUID of the coresponding field item. This will work. There is probably a format to respect as well.

It seems like there is a delay.

A delay when you do what?

Could be indexing updates on the background.

Indexing and search are 2 different things. Indexing does not affect search performances.

Gravatar for

Comment by DEEPTHI KATTA, Jan 3, 2017 6:06 PM

Hey There!

Thank you for your response. It is good to know that it is indeed a bug. So, quick question when you say use GUID - I dont think I see an option to enter GUID from the UI provided when you click on custom field for sorting. Can you confirm? Do we pass in GUID from JS or something? Can you provide insight on to how to achieve this. We were leaning towards using OOTB functionality and not do code changes as we are close to go live.

Gravatar for

Comment by Sébastien Belzile, Jan 4, 2017 9:12 AM

Previous to June 16, the UI provided to select a field would display a list of template + a list of fields when a template was selected. Selected fields were Sitecore items, meaning the control was saving the field name as a GUID.

This has been replaced by a text box with a Select field button mostly for scaling reasons. Is this what you have?

Clicking on Select field opens a modal were a text box is displayed. The textbox auto suggests fields. Instead of writing a field in it, simply write the GUID of your Sitecore field item.

Gravatar for

Comment by DEEPTHI KATTA, Jan 17, 2017 8:18 PM

Thank you. Yes, we have the modal where text is displayed. I can type and it suggests, yep. So, your suggestion is to use GUID of sitecore field in that textbox instead of typing field name? Then, it is super awesome and we would not need customization or additional JS code. I will try this out tomorrow, but, if you can confirm if I am in correct path. It would be awesome

Gravatar for

Comment by Sébastien Belzile, Jan 17, 2017 8:35 PM

Yes, I confirm that you are on the correct path.

Gravatar for

Comment by priyajoshi, Jan 27, 2017 1:05 AM

I am part of the OP's team and tried this solution in order to set the sort order by field. As per your instructions, I set the GUID of the sort order field and set the order. While the sorting works on descending, if I change the sort order to ascending it does not take up the change and always sorts in descending. Is this a bug? Below are the details of what I am trying to achieve.

  • Default Sort Type : Field
  • Default Sort Direction : Ascending
  • Default Sort field : {GUID of the field}
Gravatar for

Comment by Sébastien Belzile, Jan 27, 2017 8:03 AM

Can you tell me what is output on your search page? (attach a debugger before the coveoForSitecore.init call and look at the options).

Could you tell me what is the order defined in your query? (look at the HTTP call in your browser developer tools)

Gravatar for

Comment by DEEPTHI KATTA, Jan 30, 2017 7:55 PM

Just to update for everyone else who is looking for a solution, if tabs on your rendering are using same field for sort, you can place default sort order and field on Coveo rendering properties instead of tab based. When I did this, I see that on json call the sort criteria is being passed correctly.

Gravatar for

Comment by DEEPTHI KATTA, Feb 27, 2017 3:03 PM

Hi There!

Quick comment on this, the fix suggested works on Custom coveo Search View when set directly. But, it is not working on tab level? Is there a workaround to actually have this Guid thing working on Individual tab? A workaround would hugely help us.

Gravatar for

Comment by François Lachance-Guillemette, Feb 27, 2017 3:29 PM

It is mentioned in the documentation that you also need a sort component matching your default sort. Did you add one?

Gravatar for

Comment by DEEPTHI KATTA, Mar 1, 2017 2:14 PM

Hi There!

That is helpful to know, no, I dont think I did any additional steps other than selecting a default order field and Guid on Tab Rendering on presentation. The documentation says " A Sort component configured with the same specified parameter needs to be in the interface in order for this this option to function properly." I am kind of confused on this statement and would like to implement and test this the right way. Is there any other documentation I can refer to for understanding how to do sorting on Tab component the right way. Would love to use renderings to promote sort component on the rendering of presentation rather than through JS if that is supported to keep things clean

Gravatar for

Comment by François Lachance-Guillemette, Mar 1, 2017 2:49 PM

In other words, say you have defined field, ascending and updateddate as your default sort in your tab, you need a sort component defined as field, ascending and updateddate.

The default sort on the tab is used to generate a criteria, and you must have a Sort component with the exact same criteria.

Gravatar for

Comment by DEEPTHI KATTA, Mar 2, 2017 2:53 PM

I see!! Much helpful. I will try this out and keep you posted. :) Thanks a ton as always.

Gravatar for

Comment by DEEPTHI KATTA, Mar 3, 2017 3:59 PM

Hey There!

Just tried the below -

  1. On My Tab Component, I added Default Sort Order using GUID on the field of my interest and passed in Type, Field and Order
  2. Then, on my newly added Sort Component, I ensured I pass the exact same things I selected in step #1, in this case I do not need to pass GUID, the name of the field works.

I am assuming I can show/hide Sort Components based on Tab just like any other facets. If yes, then, I think we should be good here.

Gravatar for

Comment by François Lachance-Guillemette, Mar 3, 2017 4:32 PM

So it did work? :)

You can validate that the sort criteria is the same by inspecting the DOM (with Chrome, right-click on the component, Inspect Element). You should see data-sort="YOUR_CRITERIA" here, and you should have a sort with data-sort-criteria="THAT_SAME_CRITERIA.

And yes, Show/Hide component should work with sorts. In fact, it works with anything that outputs an HTML element with an id="someid" and inherits the Base Id Component template.

Gravatar for

Comment by DEEPTHI KATTA, Mar 17, 2017 11:13 PM

Hey there! All is well and it works @François Lachance-Guillemette

But, I do have a situation, now it is all well when the sort is on actual sitecore field, I can use the work around which is using GUID, but, what if it is say a computed field and more like a string field that I would make IsSortable as true through configuration for example. What can I do in this case to make sorting work on this computed field. I can not obviously have a field ID in this case, I can only pick the field I am interested in through that dialog you guys have up.

And I am pretty sure it will not work. Can I give like raw coveo has field name that I could grab from index? Or is there a cleaner way. For some reason, I am running in to wall for some reason or other this regards.

Gravatar for

Answer by DEEPTHI KATTA, Mar 21, 2017 12:14 AM

Hi There!

I think I found a way to do this, what I did is force the field name to use coveo helper that will pick the actual coveo field name rather than hard coding it, no matter what I give on Default sort order, I will override on code to use the correct one.

Something like -

CoveoForSitecore.componentsOptions["mirTab"].sort = '@(Model.ToCoveoFieldName("homeNeighborhood")) ascending';

Ask a question