Copied to clipboard

Flag this post as spam?

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


  • Fredrik 89 posts 108 karma points
    Dec 22, 2011 @ 11:50
    Fredrik
    0

    Backend search indexing

    I have programmatically changed the name of a node by using the following code.

    User author = User.GetUser(0);
    Document doc = sender;
    doc.Text = doc.getProperty("myProperty1").Value.ToString() +
    doc.getProperty("myProperty2").Value.ToString();
    umbraco.library.UpdateDocumentCache(doc.Id);

    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?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 22, 2011 @ 12:44
    Dirk De Grave
    0

    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

  • Fredrik 89 posts 108 karma points
    Dec 22, 2011 @ 13:15
    Fredrik
    0

    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.

    HttpException (0x80004005): Request timed out.

     

     

  • Fredrik 89 posts 108 karma points
    Dec 22, 2011 @ 14:17
    Fredrik
    0

    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?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 22, 2011 @ 14:20
    Dirk De Grave
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft