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 ?
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.
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*
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/
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 ?
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??
Have you tried setting 'supportUnpublished' to false on the indexer at ExamineSettings.config?
https://our.umbraco.com/documentation/Reference/Config/ExamineSettings/
Thanks @August
Do you know how to implement this on Umbraco8 ? , because Umbraco8 project doesn't have Examine config file.
I'm having the same issue in Umbraco 8. How can we exclude the deleted nodes from appearing in the search?
Hi, all, I have the same issue. My query returns deleted records. Does anyone have a solution?
Mila
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:which is why I attach to ContentService.Trashing. So In ContentService_Trashing method I manually remove this item from the search idnex:
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
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*
I found checking the
parentID != -1
worksDoes anyone knows how to setup
supportUnpublished
in Umbraco 10?I believe we no longer have the file ExamineSettings.config
is working on a reply...