My problem is that the backend search doesnt go with the changes. It hits on the original value of doc.text. I guess this is a question about search indexing for the umbraco backend search. How is it done?
You need an extra doc.Publish(user) (see this wiki article) to make sure doc gets published, and that will trigger the indexing process. Last statement must remain there as well.
I get the feeling that it gets stuck in a loop since this code is run within the event void Document_AfterPublish(Document sender, PublishEventArgs e). Is there a way to disable event firing and then enable it after my code has been executed?
Ouch, yup, you'll end up in a endless loop. Disable firing is probably not the best and safest way to do this. I'd look into moving your code into another event, most probably the AfterSave or BeforePublish to avoid these loops.
Backend search indexing
I have programmatically changed the name of a node by using the following code.
My problem is that the backend search doesnt go with the changes. It hits on the original value of doc.text.
I guess this is a question about search indexing for the umbraco backend search. How is it done?
Hi Fredrik,
You need an extra doc.Publish(user) (see this wiki article) to make sure doc gets published, and that will trigger the indexing process. Last statement must remain there as well.
Cheers,
/Dirk
Ok. My code now look like this:
User author =User.GetUser(0);
Document doc = sender;
doc.Text= doc.getProperty("myProperty1").Value.ToString()+
doc.getProperty("myProperty2").Value.ToString();
doc.Publish(author);
umbraco.library.UpdateDocumentCache(doc.Id);
Now I get a timeout exception.
I get the feeling that it gets stuck in a loop since this code is run within the event void Document_AfterPublish(Document sender, PublishEventArgs e). Is there a way to disable event firing and then enable it after my code has been executed?
Ouch, yup, you'll end up in a endless loop. Disable firing is probably not the best and safest way to do this. I'd look into moving your code into another event, most probably the AfterSave or BeforePublish to avoid these loops.
Cheers,
/Dirk
is working on a reply...