Copied to clipboard

Flag this post as spam?

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


  • DitlevHB 6 posts 66 karma points
    Sep 22, 2014 @ 04:40
    DitlevHB
    0

    Problem with modifying Examine Lucene.Net Index with event hook (ezSearch)

    I have stumpled upon a problem with modifying the index in the eventhook DocumentWriting.

     

    Here are the details of what process i have been through.

    I am hooking the event DocumentWriting to access the point of creation of the index, so i can manipulate the data in the index. I have successfully added a field to some documents, but heres the problem.

    Using luke for looking up the index i noticed, that the modified documents are only of the Indextype media.

    I have in total 34 documents, but the only documents containing the newly added field are documents of the type media.

    My goal is to target all documents and add a single field to all of them.

    Here is the code

    public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, 
                ApplicationContext applicationContext)
            {
    
                var indexer = (UmbracoContentIndexer) ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"];
                indexer.DocumentWriting += indexer_DocumentWriting;           
    
            }
    
    private void indexer_DocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e)
            {
    
                // Grab the Lucene document from the event arguments
                var doc = e.Document;
    
                doc.Add(new Field("acitivy", "zumba", Field.Store.YES, Field.Index.NOT_ANALYZED));
    
      }
    

     

    Note the methods are called in ezSearchBootstrapper.cs, that follows with the ezSearch Package

     

    UPDATE****

    I have now found, that when i republish a single node manually, the field is added to that node. What i can't seem to understand is, that it doesn't add the field to all documents, when i republish the entire site. I HAVE to publish them manually, to add the field.

     

    Any ideas of how to solve this?

     

    Thanks in advance, 

    I hope you can help me with this issue.

    Ditlev

     

     

     

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Sep 22, 2014 @ 10:22
    Ismail Mayat
    100

    Ditlev,

    What version of Umbraco are you using? Also after re publishing your xml did you manually rebuild the index? If not then you will need to rebuild it, if using v7 there is under developer section a dashboard tool to do it, if using v6 you can install http://our.umbraco.org/projects/developer-tools/examine-dashboard which will also give you ability to rebuild.

    Regards

    Ismail

  • DitlevHB 6 posts 66 karma points
    Sep 22, 2014 @ 11:17
    DitlevHB
    0

    Hello Ismail,

    I am using Umbraco 7.1.4.

    I went to the developersection - > Examine Management and found the index and rebuilt it, which works great!

    Thanks for the fast answer.

    Have a nice day.

Please Sign in or register to post replies

Write your reply to:

Draft