Is it possible to index the contents of a block, when it's rendered inside an XhtmlString property, in a similar fashion as in the ContentArea property using the IndexInContentAreas attribute?
Here is one way to do it: http://world.episerver.com/blogs/Per-Magne-Skuseth/Dates/2016/1/episerver-find-index-blocks-in-xhtmlstring/
Is there a way to do this when access to pages and blocks are restricted?
I have a page with restricted access, and the page itselt is indexed (there is text in AsViewdByAnonymous) but the blocks in the xhtmlfield (MainBody) on the page are not indexed. I used the solution in Pers blog post. My guess is that "xhtmlString.Fragments.GetFilteredFragments(PrincipalInfo.AnonymousPrincipal)" is filtering out all blocks?
I think you are guessing correctly! :-)
Yes but why? And why are not everything in MainBody filtered out since access is restricted?
Pages are by default indexed regardless of restrictions. You would use FilterForVisitor() during querying to exclude those with restricted access.
Thanks for the clarifications!