November Happy Hour will be moved to Thursday December 5th.

Content indexer conventions clarification?

Vote:
 

Hi,

I recently bumped into a possible issue, can't really determin if this is by design or a bug so I thought I'd raise the question here.

I've written an indexing convention that is based on a boolean property on a specific page like this:

ContentIndexer.Instance.Conventions
              .ForInstancesOf()
              .ShouldIndex(x => !x.ExcludeFromSearch);

When adding a page with this property set to true it does not get indexed - everything is peachy.

However, when saving a page that previously had this property set to false the item in the index does not get removed nor updated with the new value.

Should indexing conventions not remove the item from the index if a property is updated that makes the item invalid?

Surely one would not have to empty the index and perform a complete reindexing for this to work?

Thanks!

#162205
Oct 12, 2016 14:01
Vote:
 

So obviously this was by design and the following workaround has to be put in place:

ContentIndexer.Instance.Conventions.ForInstancesOf<Page>()
                .ShouldIndex(x =>
                {
                    var shouldIndex = !x.ExcludeFromSearch;
                    if (!shouldIndex)
                    {
                        try
                        {
                            ContentIndexer.Instance.Delete(x);
                        }
                        catch
                        {
                            //ignore
                        }
                    }
                    return shouldIndex;
                });
#162211
Oct 12, 2016 15:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.