Sitecore ContentSearch is not providing result in the same order like Solr query does.


we are getting result in the following order

  1. x
  2. y
  3. z

but when we use ContentSearch API we are getting results in different order.

var results = Sitecore.ContentSearch.ContentSearchManager.GetIndex("sitecore_web_index").CreateSearchContext().GetQueryable<Sitecore.ContentSearch.SearchTypes.SearchResultItem>().Where(x => x.Content.Contains("testorder")

when we iterate the list, we get different order:

  1. y
  2. x
  3. z

How can I get results from ContentSearch in the same order as Solr?

  • What is the raw query that Sitecore is executing when you run that ContentSearch code in your question? (You can find this by checking the Search logs in your data folder: /data/logs/Search.log.DDDDDDDD.TTTTTT.txt.) My guess is that it's a different underlying query which causes the difference in result order. Jan 17, 2019 at 2:42
  • 1
    Thanks for the info. x.Content.Contains("testorder") form query like q=_content:*testorder* . to get q=_content:testorder, we have to use x.Content=="testorder"
    – User192019
    Jan 17, 2019 at 3:27
  • also sitecore linqtosolr support equal method
    – pblrok
    Jan 17, 2019 at 8:00

2 Answers 2


The easiest way to troubleshoot issues like this is to review the search logs to see what query Sitecore is building behind the scenes:

  1. Execute your code that performs the search
  2. Load the latest search log file (located in your data folder: /data/logs/Search.log.DDDDDDDD.TTTTTT.txt)
  3. Find your search and see how it was constructed

Based on your code and subsequent comment, it looks like the solution to your issue is to change your ContentSearch code from x.Content.Contains("testorder") to

x.Content == "testorder"

x.Content.Contains("testorder") forms the Solr query q=_content:*testorder*

To get q=_content:testorder, we have to use x.Content == "testorder"

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.