Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • whitter 2 posts 22 karma points
    Mar 31, 2020 @ 16:26
    whitter
    0

    Document staying in index after validation returned ValueSetValidationResult.Failed

    Hi, I'm currently attempting to setup some document validation on indexing and running into an issue.

    Previously in Umbraco 7 I have setup custom indexers and overwritten ValidateDocument function to add in extra checks to not have a document index. These checks have all been based on some data within the document being index, such as a simple flag that the CMS admin can use to not have the document searchable and more advanced ones that prevent a document from being index based on some child node values.

    I am currently trying to recreate the same process in Umbraco 8. I've created a custom IValueSetValidator and it is working as expect, the only thing that is not working is that on returning ValueSetValidationResult.Failed the document is not removed from the index.

    In Umbraco 7 and Examine when a document failed validation it was removed:

    case IndexOperationType.Add:
      if (ValidateDocument(item.Item.DataToIndex))
      {
         var added = ProcessIndexQueueItem(item, writer);
         indexedNodes.Add(added);
      }
      else
      {
         ProcessDeleteQueueItem(item, writer, false);
    
         OnIgnoringNode(new IndexingNodeDataEventArgs(item.Item.DataToIndex, int.Parse(item.Item.Id), null, item.Item.IndexType));
      }
    break;
    

    Where as in Umbraco 8 the validation check is only performing actions on documents that have not failed:

    PerformIndexItems(values.Where(x => ValidateItem(x) != ValueSetValidationResult.Failed), OnIndexOperationComplete);
    

    Is there an alternative way to dynamically not have documents indexed and subsequently removed?

    My only other thought on how to accomplish this is to dynamically add a field to the index that flags whether the document should be returned in a set of results and filter on it during search. Seems a little excessive based on have it was previously done in 7.

    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft