Copied to clipboard

Flag this post as spam?

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


  • John 4 posts 54 karma points
    Jun 22, 2020 @ 09:00
    John
    0

    Examine - Getting IndexSetName from Searcher

    HI folks,

    I would like your help on extracting the IndexSetName from a Searcher. You can see the IndexSetName is available under each searcher. You can see this in ProviderProperties.

    The reason I'm doing this I'm developing a plugin/package where you choose a Searcher e.g ExternalSearcher, InternalSearcher or any other.

    I have to get the IndexSetName to create an event handler for GatheringNode.

    ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"].GatheringNodeData += MediaSearchController_GatheringNodeData;
    
    var Searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
    

    I'm trying to avoid hardcoding the name of the Searcher (ExternalSearcher) and IndexSetName (ExternalIndexSet).

    So I would select ExternalSearcher from a dropdown and it passes this name "ExternalSearcher" as a variable SearcherTypeName into the SearchProviderCollection.

    var Searcher = ExamineManager.Instance.SearchProviderCollection[SearcherTypeName];
    

    I need to do the same for ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"]

    How I get the IndexSetName from my choice of Searcher i.e. "ExternalIndexer"?

    Is there a better of getting the IndexSetName? Would ExternalSearcher and ExternalIndexer always be available in all of Umbraco 7 installations?

    Can you please help?

    Update: This is what I can see from the Searcher properties. It's a bit limited

    enter image description here

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 22, 2020 @ 10:30
    Ismail Mayat
    100

    John,

    I have done with indexers and you have to cast it to LuceneIndex then you can get to the properties, I suspect you have to do something similar for searcher? Take a look at examine code and see what base class searcher implements.

    Regards

    Ismail

  • John 4 posts 54 karma points
    Jun 22, 2020 @ 11:54
    John
    0

    Hi Ismail,

    That fixed the issue. You've pointed me in the right direction. I needed LuceneSearcher.

    var searchIndexer = (Examine.LuceneEngine.Providers.LuceneSearcher)ExamineManager.Instance.SearchProviderCollection[2];
    
    var indexSetName = searchIndexer.IndexSetName;
    

    With this code, I was able to get the IndexSetName.

    Thanks for your help, Ismail! :)

Please Sign in or register to post replies

Write your reply to:

Draft