1

I have created a custom search results web part which implements some simple sorting, for example i have this piece of code which allows me to sort it desc/asc by title:

    CoreResultsDatasource dataSource = this.DataSource as CoreResultsDatasource;

    if (!string.IsNullOrEmpty(OrderByProperty))
    {
       // change the sortorder
       dataSource.SortOrder.Clear();
       dataSource.SortOrder.Add(OrderByProperty, SortDirection);
    }

Basically it works for the title, but when i want to sort by Modified Date, it doesnt work, i get an error in the webapart:

Property doesn't exist or is used in a manner inconsistent with schema settings.

I did try to add it in: Core Search Results Display Metadata => Properties

But still nothing happens.

Any idea how can i do it?

PS: I tried to pass "ModifiedDate" and i tried to pass "LastModifiedTime" Another strange issue i notice is that when i pass a title outside of search center it breaks i get an "Internal error" no errors in the log.

3
  • When you are trying to sort by Modified Date, which OrderByProperty name you are passing? Commented Feb 20, 2013 at 10:06
  • I tried: "ModifiedDate" and i tried "LastModifiedTime"
    – Shkipper
    Commented Feb 20, 2013 at 11:00
  • Ivan is correct, you should use exact managed property name, for Modified date it is write managed property. Also, delete all none existing managed properties from Core Search Results Display Metadata => Properties to error disappear. Commented Feb 20, 2013 at 11:54

1 Answer 1

2

you can only provide sorting on managed properties. Look for the exact name of the managed property in central administration. I have similar web part and it works for me. Maybe look if the crawled property is correctly assigned to managed property.

5
  • Same web part? Does it work also outside of search center? And the filter works perfectly? And what peoperty exactly you use?
    – Shkipper
    Commented Feb 20, 2013 at 12:09
  • yes it works outside of search centre. using it for showing last 5 documents by mod date. in text box for order property name i have "LastModifiedTime", in fixed query : scope:"MyDocuments". Probably look if 2 or more web parts on one page does not have the same value in 'Cross web part query id'. i had issues with this.
    – Ivan
    Commented Feb 20, 2013 at 12:16
  • also be aware that if you are doing filtering in fixed query there are som strange restrictions and rules, look at here and here
    – Ivan
    Commented Feb 20, 2013 at 12:31
  • Yes Ivan i think i have same webpart as you do, but when i add this LastModifiedTime, i get "Property doesn't exist or is used in a manner inconsistent with schema settings. " Although it is default property ...
    – Shkipper
    Commented Feb 20, 2013 at 12:49
  • probably past here all the sections where you are using this property, maybe there is really just small typo
    – Ivan
    Commented Feb 20, 2013 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.