After the creation a page test for item, which is recorded to SOLR index, in Experience Optimization and creation some page versions to test against (during the test creation), when I get items from that index in code (using indexContext.GetQueryable<SearchResultItem>()) to display their content, I get all versions of the item involved in page test. How should I determine which version to choose and display? And based on what rules are certain versions of pages displayed to certain users?

  • Hi bavad - first question I have is to clarify if there are any business rules around your versioning or is it assumed the latest version is to be displayed? If so, you could use the __Updated or __Created fields from your index to select the version. As to the users, I'm not sure exactly that is being asked. Are you asking an for an example, advise or again is there a business process you can clarify for us? Thanks. Best Wishes. Feb 19, 2019 at 22:44
  • You can filter by _latestversion version field on query search Feb 20, 2019 at 5:09
  • @JustinBradley I don't have any custom business rules around my versioning. Several versions of the item are used to test against each other in page test, so that one version should be displayed to some users, another version should be displayed to other users (I didn't find information if there are any default rules in Sitecore to make it possible or versions are chosen randomly).The question is - how should I determine which version to choose to display to facilitate the correct Sitecore page testing - should I choose them randomly or retrieve some rules from Sitecore and apply them somehow?
    – bavad
    Feb 20, 2019 at 9:04
  • @bavad - Thanks for the details. I personally don't believe this is a good case for using tests like this. One suggestion if you wanted to try it out would be to create a datasource for your items that has a settings field that can actually be executed as a solr query and so for each item it queries a different version based on that field. Does this make sense? Best Wishes. - Justin Feb 20, 2019 at 22:27

1 Answer 1


As mentioned above there is a _latestversion bool field if the current search result is the latest version of the language. I didn't find this field in the basic SearchResultItem class so a new class can be created that would use this field. So this field can be used in the condition and also a condition for the language to match the context language should be added:

predicate = predicate.And<SearchResultItem>(item => item.Language == Context.Language.Name);

Your Answer

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

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