Copied to clipboard

Flag this post as spam?

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


  • Maff 141 posts 466 karma points
    Oct 29, 2014 @ 14:06
    Maff
    0

    ezSearch not displaying content that has Public Access restrictions set

    I've set up ezSearch straight out of the box and it's working fine (and I love it!)

    However, as soon as I change the Public Access rights of a piece of content to be only availble to a specific Member Group, it disappears from the search results - even if I'm logged in with a user from that Member Group!

    Digging into the ezSearch code, I've found the function that does the search (line 115):

    var results = searcher.Search(criteria2)

               .Where(x => (

                    !Umbraco.IsProtected(int.Parse(x.Fields["id"]), x.Fields["path"]) ||

                    (

                        Umbraco.IsProtected(int.Parse(x.Fields["id"]), x.Fields["path"]) && Umbraco.MemberHasAccess(int.Parse(x.Fields["id"]), x.Fields["path"])

                    )) && (

                        (x.Fields["__IndexType"] == UmbracoExamine.IndexTypes.Content && Umbraco.TypedContent(int.Parse(x.Fields["id"])) != null) ||

                        (x.Fields["__IndexType"] == UmbracoExamine.IndexTypes.Media && Umbraco.TypedMedia(int.Parse(x.Fields["id"])) != null)

                    ))

                .ToList();

    The protected content is missing even if I strip out all the .Where() clauses and just use this:

    var results = searcher.Search(criteria2).ToList();

    Is this a bug with Examine, ezSearch or user error?

    Thanks,

    Maff

  • keilo 568 posts 1023 karma points
    Nov 10, 2014 @ 17:10
    keilo
    0

    Hi Maff

    Did you figure out a solution with the protected page search?

  • Maff 141 posts 466 karma points
    Nov 10, 2014 @ 17:19
    Maff
    0

    Hi Kielo,

    Yes I figured this out out.

    First, I had to add an extra line to the ezSearchBootstrapper.cs file, to make it aware of the "Internal" Examine index - I added this line to the OnApplicationStarted() method (line 23):

    ExamineManager.Instance.IndexProviderCollection["InternalIndexer"].GatheringNodeData += OnGatheringNodeData;

    Then I had to make changes to the ezSearch.cshtml file (the one stored in MacroPartials) to tell it which index to search from depending on if the user is logged in or not.

    There is a line in there that by default uses the External Examine index:

    var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];

    and I changed this to allow use a parameter that I pass into the page:

    var searcher = ExamineManager.Instance.SearchProviderCollection[indexToSearch];

    Cheers,

    Maff

  • keilo 568 posts 1023 karma points
    Nov 10, 2014 @ 18:02
    keilo
    0

    Hi Maff

    Interesting... that line have the ExternalIndexer by default. Did you replace it with Internal or add next to the Internal (sorry if that sounds dumb, im learning as i go along)?

    do you mean to say you have changed the line 23 function at ezSearchBootstrapper.cs to be like;

      public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication,  ApplicationContext applicationContext)

            {

                ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"].GatheringNodeData += OnGatheringNodeData;

       ExamineManager.Instance.IndexProviderCollection["InternalIndexer"].GatheringNodeData += OnGatheringNodeData;

            }

    and that allowed both Internal and External Index to be available for 

    var searcher = ExamineManager.Instance.SearchProviderCollection[indexToSearch];

    where indexToSearch is the parameter you pass with value of InternalIndexer or ExternalIndexer - based on if user is logged in or not?

    Am I following this correctly?

    Its interesting indeed, that protected page support is not thought of. I dont think we are only ones who will be looking for such solution...

     

  • Maff 141 posts 466 karma points
    Nov 10, 2014 @ 18:10
    Maff
    0

    Hi Kielo,

    I have both lines in there, to allow ezSearch to access either index:

    public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)

            {

              ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"].GatheringNodeData += OnGatheringNodeData;

              ExamineManager.Instance.IndexProviderCollection["InternalIndexer"].GatheringNodeData += OnGatheringNodeData;

            }

    and yes you are correct with the indexToSearch parameter - this should be set to either "ExternalIndexer" or "InternalIndexer"

    Cheers,

    Maff

  • Harish 15 posts 74 karma points
    Nov 19, 2014 @ 15:17
    Harish
    0

    I have tired the way you said......but getting error message as, error loading partial view script (file: ~/Views/MacroPartials/ezSearch.cshtml) 

    what exactly you want me to put in .cshtml 

    I have removed this line 

    var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"]  and added below line

    var searcher = ExamineManager.Instance.SearchProviderCollection[indexToSearch];

    Thanks in advance


     

     

     

     

     

  • keilo 568 posts 1023 karma points
    Nov 19, 2014 @ 15:21
    keilo
    0

    Hi Harish

    I dont think you need to remove that line, as what Maff commented, the line is added to existing.

    Then you can follow Maff's suggestion to edit the file in your Umbraco installation and change Search provider if user logged in and dont change it not logged in 

    /Views/MacroPartials/ezSearch.cshtml

  • Harish 15 posts 74 karma points
    Nov 19, 2014 @ 15:48
    Harish
    0

    Hi Keilo, 

    Thanks for your reply ....but still did not work.....

    dont know what to do....

    Many Thanks

     

  • Harish 15 posts 74 karma points
    Nov 19, 2014 @ 21:27
    Harish
    0

    hi 

    when given indexToSearch, then complaining about could not find indexToSearch....

    should i decalre else where in .cshtml...

    please reply as soon as possible.....

    Thanks in advance....

     

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    May 18, 2015 @ 16:24
    Jeroen Breuer
    0

    Isn't it easier to just let the ExternalIndexer also index protected nodes if that's not a problem? 

    <add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine" supportProtected="true"/>

    Jeroen

  • Ryan Dansie 17 posts 98 karma points
    Mar 15, 2016 @ 11:12
    Ryan Dansie
    0

    That worked for me thanks. For future reference:

    Open the "/Config/ExamineSettings.config" file.

    Change this line:

    <add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine" />
    

    to this:

    <add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine" supportProtected="true" />
    
  • Michele Di Maria 34 posts 239 karma points
    May 27, 2016 @ 14:35
    Michele Di Maria
    0

    I just incurred into this, I was getting mad... thanks for the info!

    Michele

Please Sign in or register to post replies

Write your reply to:

Draft