How to work with Sitecore Content Search and Page Editor

I rewrote the news app (review + detail) from a quick content search query. The performance has been tremendous, but I see some possible limitations that I am not aware of to handle in conjunction with the Page Editor.

  • When I use quick query, I get a news instance even if there is no language version yet. In Lucene I cannot find the result (because I am filtering for the language) and therefore there is no news information in the specific language overview.

EDIT for question 1

Let's assume we have a solution with two languages ​​(English and German). I have an item that currently only exists in one English version. When I am on the overview page in German and I want to search for this item with a quick query (query does not matter), I will return that item. In the wrong version, but I will return it. Now if I'm in the Page Editor, I can go to that item and edit it in German, even if there is no version yet. The first click on the save button will create the first version for me.

When I want to find an item via Content Search, my natural way to query is to do the same filter (perhaps by pattern, path and some channel or the like) AND filter by the SearchResultItem language property, since I don't want multiple results for the same the same item. But since there is only English version, the index only contains one English result and due to the language filter, I cannot find this item to call GetItem on it.

From the very beginning of writing this question, I see two approaches to get around this:

a) Remove the language filter in page editor mode and filter it somehow (I don't know if I can get an item that I can edit in the page editor in German)

b) Create a dedicated page editor main search index that contains an entry for all languages ​​in the solution for each item, even if it does not exist in the specific language. I can add a calculated field to indicate if this result is a real version of the element, or not filter at some point if needed. I can probably go to GetItem and enable the Page Editor capabilities.

  1. With lucene, I cannot find a part item in a (currently) non-existent language version when I want to resolve it with a display name via Lucene (since no language version has been specified yet).

EDIT for question 2

This goes hand in hand with question 1

  1. With regard to Workflows, I see a possible fight against the indexed version. Is the first version in the index before you approve the version? Otherwise, the review has no chance of showing the item until it is approved in the Content Editor.

Has anyone used the appropriate content search steps for the page editor and have some guidance on how to get around such issues?

+3


source to share


1 answer


I had the same problems with Sitecore 7, and while I don't have a definitive solution for you, I hope you find the following information helpful.

I cannot formulate my answer better than this post: http://thegrumpycoder.com/post/75524076869/sitecore-content-search-beware-of-the-context

With Sitecore ContentSearch, you choose which search index you would like to use. You are probably using sitecore_master_index in Editor / Page Preview and sitecore_web_index on the published site. Since there is only one version of each item in the web database, you don't have to worry about them having multiple versions in the index. However, sitecore_master_index will by default index all versions of an item in all languages. Then you can see the items appear multiple times in your list components if you're not careful.

Sitecore 7 has a "_ lastversion" field that you can add to all your requests, but it is not reliable for several reasons:

  • The latest version is not necessarily correct, considering things like publication restrictions and the date you selected in the Experience view.
  • Due to a bug, I could often call more than one version of an item in the index where _latestversion is 1. Not after a complete rebuild, but after an edit or two. I've seen this in Sitecore 7.0 and I'm not sure if it's fixed yet.


Read http://www.sitecore.net/Learn/Blogs/Technical-Blogs/Sitecore-7-Development-Team/Posts/2013/04/Sitecore-7-Inbound-and-Outbound-Filter-Pipelines.aspx to get more information on how you can use the "Inbound Filters" to ensure that only the latest version turns it into the main index, but keep in mind that I am not really solving the main problem as the latest version is not necessarily correct.

So, given the fact that you need language fallbacks, you should probably not be filtering those results at the Lucene level, but doing the necessary magic yourself in code. It's necessary:

  • Group versions together with their elements
  • Choose the correct version based on your current language, date, security, and workflow.
  • Apply your desired fallback logic if the specified version is not found
  • Somehow working with pagination in a way that works well

I also believe the following SO question is relevant: Sitecore Indexing Item security and limiting search results returned is something else that might catch you when you expect the Search API to work exactly the same as the Query API.

I would be interested to know your thoughts and if you ever find a better solution! Thanks Steve.

+1


source







All Articles