Copied to clipboard

Flag this post as spam?

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


  • Saif Obeidat 79 posts 296 karma points
    May 30, 2019 @ 09:33
    Saif Obeidat
    0

    How to prevent Examine from returning deleted nodes?

    Hello,

    I am using Examine to return some nodes in certain document type alias.

    Refering to this document: https://our.umbraco.com/documentation/Reference/Searching/Examine/Quick-Start/

     results = searcher.CreateQuery().Field("__IndexType", "content").And().Field("__NodeTypeAlias", "client").Execute();
    

    All is perfect if there are no deleted nodes, but if there, I get some issues like counting the results and other things because of those deleted nodes.

    The question is, how to avoid deleted nodes from returning ?

  • Saif Obeidat 79 posts 296 karma points
    May 30, 2019 @ 21:44
    Saif Obeidat
    0

    I noticed that when I empty the recycle bin, the issue will be gone.but I think this wouldn't be the perfect solution.

    Can you help guys??

  • August 7 posts 117 karma points
    May 30, 2019 @ 22:00
    August
    0

    Have you tried setting 'supportUnpublished' to false on the indexer at ExamineSettings.config?

    https://our.umbraco.com/documentation/Reference/Config/ExamineSettings/

  • Saif Obeidat 79 posts 296 karma points
    Jun 10, 2019 @ 10:05
    Saif Obeidat
    0

    Thanks @August

    Do you know how to implement this on Umbraco8 ? , because Umbraco8 project doesn't have Examine config file.

  • James Hull 4 posts 24 karma points
    Jun 17, 2019 @ 06:50
    James Hull
    0

    I'm having the same issue in Umbraco 8. How can we exclude the deleted nodes from appearing in the search?

  • Mila Pandurska 75 posts 354 karma points
    Jun 25, 2019 @ 07:26
    Mila Pandurska
    0

    Hi, all, I have the same issue. My query returns deleted records. Does anyone have a solution?

    Mila

  • Mila Pandurska 75 posts 354 karma points
    Jun 25, 2019 @ 11:48
    Mila Pandurska
    0

    I found a work around. I attach to ContentService.Trashing += ContentService_Trashing; event. Keep in mind that when you delete an item in the umbraco admin none the following event is fired:

     ContentService.Deleting 
     ContentService.Deleted
    

    which is why I attach to ContentService.Trashing. So In ContentService_Trashing method I manually remove this item from the search idnex:

    private void ContentService_Trashing(IContentService sender, MoveEventArgs<Umbraco.Core.Models.IContent> e)
            {
         foreach (var item in e.MoveInfoCollection)
                {
                    if (item.Entity.ContentType.Alias ==  "articleDetailsPage")
                            {
                                IIndex index;
                                if (_examineManager.TryGetIndex("NewsSearchIndex", out index))
                                {
                                    index.DeleteFromIndex(item.Entity.Id.ToString());
                                }
                            }
    
    
                                IIndex index;
                                if (_examineManager.TryGetIndex("ExternalIndex", out index))
                                {
                                    index.DeleteFromIndex(item.Entity.Id.ToString());
                                }
                    }
                }
    }
    

    In my code I have configured custom index for my articles. If the element is articleDetails it should be removed from my custom index and the external idex as well.

    Regards Mila

  • Yakov Lebski 591 posts 2345 karma points
    Jun 27, 2019 @ 10:37
    Yakov Lebski
    0

    I think it can be an issue when rebuilding indexes, in v7 it easy supportUnpublished=false as was sad before

    without access to ExamineSettings.config I think it can work with query over path property, when page deleted it moved under -10 query should be not in path: -10*

  • Jason Soderberg 7 posts 32 karma points
    Sep 10, 2021 @ 19:48
    Jason Soderberg
    0

    I found checking the parentID != -1 works

    if (Int32.Parse(result.Fields["parentID"] .ToString()) != -1)
    {
    
    }
    
  • Mayara Ferreira 4 posts 94 karma points
    Aug 28, 2023 @ 15:14
    Mayara Ferreira
    0

    Does anyone knows how to setup supportUnpublished in Umbraco 10?

    I believe we no longer have the file ExamineSettings.config

Please Sign in or register to post replies

Write your reply to:

Draft