Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Index blocks that are not on a page

Vote:
 

Hi,

I would like to index blocks that are not being used anywhere. Is this possible or do the blocks need to be on a page in order to be indexed. If it is possible what do I need to do for this to happen (custom index job?)?

Thanks,

Mark

#152122
Aug 17, 2016 12:29
Vote:
 

Ok an update on this, in the current project I'm working on shared blocks are not being indexed but an older project shared blocks are being indexed (which I would expect based on what I've read). I can't see any obvious differences between the blocks in each project or think of any other setting that may prevent shared blocks being indexed.

Any thoughts?

#152125
Aug 17, 2016 13:32
Vote:
 

Tried using conventions to turn it on?

//using EPiServer.Find.Cms.Conventions;
ContentIndexer.Instance.Conventions
  .ForInstancesOf<BlockData>()
  .ShouldIndex(x => true);

Something like that at application start...

#152127
Aug 17, 2016 14:33
Vote:
 

Hi Daniel, I tried that and it made no difference. The project where blocks are being indexed does not have this code either.

#152154
Aug 18, 2016 10:04
Vote:
 

Can you post all of your conventions code?

#152186
Aug 18, 2016 22:53
Vote:
 

As Johan says, check your conventions code.

Do the index job show any errors at all?
If you are using Find version 11.1.2 or 11.1.3 there is an issue with the indexing job which could prevent all items to be indexed.

#152190
Aug 19, 2016 7:58
Vote:
 

Did you check in index in admin mode to confirm that they aren't in index? Or just searched for a block? Just to confirm it is the indexing part that is actually the problem and not when you use the client...

#152192
Aug 19, 2016 8:50
Vote:
 

Hi, to answer all your questions...

The conventions code is below, note that I am excluding all blocks but then including the block type that I need to be indexed.

        private void SetIndexConventions()
        {
            var indexer = ContentIndexer.Instance;
            //nb: default is to index "all CMS content" so we need to exclude what we don't want

            //exclude blocks
            indexer.Conventions.ForInstancesOf<BlockData>().ShouldIndex(i => false);
            
            //But we need to include this block
            indexer.Conventions.ForInstancesOf<BlahBlahDataBlock>().ShouldIndex(i => true);                       
        }

There are no errors in the indexing but it doesn't look like it's indexing everything:

Indexing job [My Website] [content]: Reindexing completed. ExecutionTime: 0 hours 0 minutes 1 seconds Number of contents indexed: 23
Indexing job [Global assets and other data] [content]: Reindexing completed. ExecutionTime: 0 hours 0 minutes 0 seconds Number of contents indexed: 0

I'm using CMS 9.11 with Find version 12.0.0

I've checked in the Find admin console to confirm the blocks are not there (the searching comes once I've got something to search for).

Thanks for all your help so far,

Mark

#152199
Aug 19, 2016 10:43
Vote:
 

And if you change it to a one line expression like

indexer.Conventions.ForInstancesOf<BlockData>().ShouldIndex(i => i is BlahBlahDataBlock);

Does that help?

#152200
Aug 19, 2016 10:57
Vote:
 

I have other conventions in that method as well but I left them out for brevity, the full method is currently

private void SetIndexConventions()
        {
            var indexer = ContentIndexer.Instance;
            //nb: default is to index "all CMS content" so we need to exclude what we don't want

            //exclude for exclude flag
            indexer.Conventions.ForInstancesOf<ContentPageBase>().ShouldIndex(i => !i.ExcludeFromSearch);  
            // Exclude any type of Folder Page (e.g. AdminFolder, Standard Folder).
            indexer.Conventions.ForInstancesOf<ContainerBase>().ShouldIndex(i => false);
            //exclude all pages inheriting no search
            indexer.Conventions.ForInstancesOf<ContentPageBaseNoSearch>().ShouldIndex(i => false);             
            //exclude images
            indexer.Conventions.ForInstancesOf<ImageFile>().ShouldIndex(i => false);
            //exclude form element blocks
            indexer.Conventions.ForInstancesOf<BlockBase>().ShouldIndex(i => false);
            //exclude blocks
            indexer.Conventions.ForInstancesOf<BlockData>().ShouldIndex(i => false);
            
            //But we need to include this block
            indexer.Conventions.ForInstancesOf<BlahBlahDataBlock>().ShouldIndex(i => i is BlahBlahDataBlock);                       
        }

And the required blocks are not indexed however if I comment out "indexer.Conventions.ForInstancesOf<ContentPageBaseNoSearch>().ShouldIndex(i => false);" the blocks are indexed (although I get an error "An exception occurred while indexing content 1227: Error getting value from 'Parent' on 'Castle.Proxies.BlahBlahDataBlockProxy'. (see log for more information) ")

So I really don't understand why that one convention would prevent blocks being indexed and why would I get that error when they are indexed?

#152209
Aug 19, 2016 11:37
Vote:
 
#152210
Aug 19, 2016 11:38
Vote:
 

Yes I have six of them

#152211
Aug 19, 2016 11:40
Vote:
 

and if you comment out this line?

indexer.Conventions.ForInstancesOf<BlockData>().ShouldIndex(i => false);

#152212
Aug 19, 2016 11:43
Vote:
 

I've tried various combinations of commenting out the conventions but only the <ContentPageBaseNoSearch> commented out includes the blocks required but with errors

#152213
Aug 19, 2016 11:48
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.