I am curious when AfterPublish is executed. I have this method
private void Document_AfterPublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e) { ExamineManager.Instance.IndexProviderCollection["SiteSearchIndexer"].RebuildIndex(); // This doesn't index the latest change, must republish to index it }
But the RebuildIndex() method still did not get the latest change I did immediately before publishing.
That happens all the time. I have to publish twice for the index to include the latest change. Why does that happen? Is AfterPublish executed prior to data being saved...??
Perfect! Thanks a lot Richard, I wasn't aware of that event.
Otherwise, what would you suggest? If you don't do that, the search result will always be out of date and useless. We can't ask clients to manually rebuild the index everytime they publish, they will forget.
What event is always triggered after a publish? What is just a different event? Do you mean the RebuildIndex()?
I have moved the RebuildIndex() to AfterUpdateDocumentCache as you said. If I don't have RebuildIndex() anywhere, the index will never get updated, and search results will always be out of date.
So what is your solution...? Sorry I still don't understand.
When is Document.AfterPublish executed?
I am curious when AfterPublish is executed. I have this method
But the RebuildIndex() method still did not get the latest change I did immediately before publishing.
That happens all the time. I have to publish twice for the index to include the latest change. Why does that happen? Is AfterPublish executed prior to data being saved...??
Thanks in advance.
This is because the document is not yet added to the XML Cache at that stage. Use the AfterUpdateDocumentCache event on the content class for that. Check out http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events for more info.
But rebuilding the index after every publish, doesn't that cause performance problems?
Thanks,
Richard
Perfect! Thanks a lot Richard, I wasn't aware of that event.
Otherwise, what would you suggest? If you don't do that, the search result will always be out of date and useless. We can't ask clients to manually rebuild the index everytime they publish, they will forget.
Hi,
This event is always triggered afer a publish so no need to ask your client for that. It's just a different event.
Cheers,
Richard
What event is always triggered after a publish? What is just a different event? Do you mean the RebuildIndex()?
I have moved the RebuildIndex() to AfterUpdateDocumentCache as you said. If I don't have RebuildIndex() anywhere, the index will never get updated, and search results will always be out of date.
So what is your solution...? Sorry I still don't understand.
is working on a reply...