Copied to clipboard

Flag this post as spam?

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


  • Dave N 13 posts 34 karma points
    Nov 13, 2014 @ 05:39
    Dave N
    0

    Adding extra fields to an index isn't working when the application first starts

    Our umbraco application has a number of indexes with calculated fields added to the index.

    Currently the fields are added in an ApplicationStarted event like so

    var Indexer = ExamineManager.Instance.IndexProviderCollection["IndexName"];
    Indexer.GatheringNodeData += IndexerOnGatheringNodeData;               

    and one of our routines to add the fields is something like this

    private void IndexerOnGatheringNodeData(object sender, IndexingNodeDataEventArgs e)
    {
    ... removed error handling
    UpdateOrAttachField(e, "searchableTeachingPeriodOfOffer", CreateLuceneSearchableString((e.Fields["teachingPeriodOfOffer"] ?? string.Empty) .Replace(" ", string.Empty), ','));   AddFields(e); ... }
    Now when we first build the indexes we just navigate to the home page and the indexes are built. It seems though that the extra fields aren't added to these indexes. If however I go to backoffice and rebuild the indexes then the extra fields are added.
    I tried moving the Application started event to a starting or initialization event, but got an error "Resolution is not frozen, it is not yet possible to get values from it.", so that doesn't seem to do the job.
    How should we do this? Or is navigating to the home page first up the wrong way to build the indexes?
    (Umbraco 7.1.4)
    tia
  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Nov 13, 2014 @ 10:29
    Alex Skrypnyk
    0

    Hi Dave,

    You don't need to specify your own 'IndexerOnGatheringNodeData', you can just use /config/ExamineIndex.config and add 'IndexSet'

    Try to look here :

    http://umbraco.com/follow-us/blog-archive/2011/9/16/examining-examine

    http://our.umbraco.org/forum/developers/api-questions/56389-Exclude-nodes-in-examineIndex

    Thanks, Alex

  • Dave N 13 posts 34 karma points
    Nov 13, 2014 @ 23:07
    Dave N
    0

    Hi Alex,

    Thanks for the reply. We do have the config files set up, but the fields we are adding are calculated fields and so we use IndexerOnGatheringNodeData, shouldn't that be used? How would you add calculated fields to the config file?

    cheers,

    Dave

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Nov 14, 2014 @ 08:32
    Alex Skrypnyk
    0

    Hi Dave,

    Umbraco has build in wrapper for Lucene, called Examine.

    http://our.umbraco.org/documentation/reference/Searching/Examine/

    You don't need override application events for gathering data, you just write it in the config file.

    Thanks, Alex

  • Dave N 13 posts 34 karma points
    Nov 16, 2014 @ 23:44
    Dave N
    0

    Hi Alex,

    I'm aware of this, again how does this help if I want to index a derived field? for example I want to add a boolean flag if a few fields are set to particular values? This does seem a fairly common practice with Umbraco/examine e.g. http://thecogworks.co.uk/blog/posts/2012/november/examiness-hints-and-tips-from-the-trenches-part-2/ . The problem I'm experiencing is that the indexes aren't being built correctly on initialisation if you use calculated fields, as I said up top. I son't see anywhere in the link you've provided that addresses this? or am I missing something?

    Thanks,

    Dave

  • Bjørn Fridal 274 posts 784 karma points
    Jun 21, 2015 @ 18:16
    Bjørn Fridal
    0

    Hi,

    I found myself in the same situtation - trying to enrich my ExternalIndexer index with additional data and I got the same "resolution is not frozen..." error.

    I solved it by moving my code from OnApplicationStarting to OnApplicationStarted.

    Cheers Bjørn

Please Sign in or register to post replies

Write your reply to:

Draft