From this article I have implement only the solution till to create the Index and no to rebuild it.
What I am trying to achieve is a better approach to update the Index and no to rebuild the entire Index every few minutes. I am trying to add a node to examine Index on publish and remove it on UnPublush and on Trashed events.
private void ApiPage_Trashed(IContentService sender, MoveEventArgs<IContent> e)
{
var nodeID = e.Entity.ContentType.Id.ToString();
try
{
ExamineManager.Instance.IndexProviderCollection["ApiPageIndexer"].DeleteFromIndex(nodeID);
var query = "Dynamic";
var searcher = ExamineManager.Instance.SearchProviderCollection["ApiPageSearcher"];
var searchCriteria = searcher.CreateSearchCriteria();
var searchQuery = searchCriteria.Field("nodeName", query);
var searchResults = searcher.Search(searchQuery.Compile()).ToList();
LogHelper.Info<string>($"node with id {nodeID} has been removed from ApiPageIndexer");
}
catch (Exception ex)
{
LogHelper.Error<ContentEvents>($"node with id {nodeID} has faild to be removed from ApiPageIndexer", ex);
}
}
(the search code exists only for the debugging)
So the code runs without any error but the Node still exist in the Index.
Am I missing something? any ideas on that?
Also does anyone know how I can add a node to the Index?
Examine index with custom data. How to Add and Remove items ?
Hi!
I have create an Examine Index with custom data following the steps from this article https://24days.in/umbraco-cms/2016/custom-data-and-examine-searching/.
From this article I have implement only the solution till to create the Index and no to rebuild it.
What I am trying to achieve is a better approach to update the Index and no to rebuild the entire Index every few minutes. I am trying to add a node to examine Index on publish and remove it on UnPublush and on Trashed events.
To achieve that I have create a event handler
First I start working with the ApiPage_Trashed
(the search code exists only for the debugging)
So the code runs without any error but the Node still exist in the Index.
Am I missing something? any ideas on that?
Also does anyone know how I can add a node to the Index?
Thanks, Thomas
I had found what was wrong, I was picking the wrong Id
this id was from the document type and no from the node. Bellow I am sharing my approach - It's working! :)
is working on a reply...