1

I am trying to show last 10 modified documents in my search query for content search web part. In my query for sorting i choose "LastModifiedTime" descending. But the query dont display the correct sort. How come?

3

Take a look at this blog post.

Solution from linked post:

One solution to this problem would be to create a result source with the query and sorting. You can then configure the Web Part to use that result source. You’d have to manage this outside of your Web Part, so if you don’t feel like adding the overhead of a result source and want all the configuration contained within the web part itself, there is another solution.

The solution is to have the JSON sort defined in the available sort orders property in the Web Part. It’s not the most obvious setting but if you don’t have this defined, your sorting won’t be applied.

Json sort example (from linked post)

[
   {
      "name":"Name and Location Sort",
      "sorts":[
         {
            "p":"Name",
            "d":0
         },
         {
            "p":"Location",
            "d":0
         }
      ]
   }
]

The “name” property is the display name that you will see in the search drop down. Even though we’re not displaying the search drop down in our Web Part you can still give it a meaningful name.

The “sorts” property contains our sort order for the search results. The “p” is the managed property name and the “d” defines whether descending order is true or false (1 is descending and 0 is ascending).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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