Copied to clipboard

Flag this post as spam?

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


  • David Armitage 414 posts 1655 karma points
    Jul 23, 2020 @ 05:58
    David Armitage
    0

    Umbraco 8 Examine How to Search Multiple DocTypes

    Hi Guys,

    Does anyone know how to search multiple doc types in Umbraco 8. I tried a couple of different ways. The usual way which used to work for Umbraco 7 doesn't seem to be working.

    Sometimes it feels like I am guessing with Examine until I get it right.

    Here is what I have tried.

    This is what I used to use for Umbraco 7 (not working for 8)

    var examineQuery = criteria.GroupedOr(new string[] { "_docTypeAliasFieldName" }, new string[] { "contentPage", "blogDetailsPage", "eventDetailsPage", "officeDetailsPage", "sectorDetailsPage", "serviceDetailsPage", "staffDetailsPage" });
    

    I had a stab in the dark here and tried this.

    var examineQuery = criteria.NodeTypeAlias("contentPage").Or().NodeTypeAlias("blogDetailsPage").Or().NodeTypeAlias("eventDetailsPage").Or().NodeTypeAlias("officeDetailsPage").Or().NodeTypeAlias("sectorDetailsPage").Or().NodeTypeAlias("serviceDetailsPage").Or().NodeTypeAlias("staffDetailsPage");
    

    Thanks in Advanced.

    Regards

    David

  • David Armitage 414 posts 1655 karma points
    Jul 23, 2020 @ 06:16
    David Armitage
    0

    Hi,

    I also tried this and no results are returned.

     var searcher = index.GetSearcher();
                    var criteria = searcher.CreateQuery(IndexTypes.Content, BooleanOperation.And);
                    IBooleanOperation examineQuery = criteria.GroupedOr(new string[] { "nodeTypeAlias" }, new string[] { "contentPage", "blogDetailsPage", "eventDetailsPage", "officeDetailsPage", "sectorDetailsPage", "serviceDetailsPage", "staffDetailsPage" });
    
  • David Armitage 414 posts 1655 karma points
    Jul 23, 2020 @ 06:25
    David Armitage
    0

    Hi Guys,

    It looks like I was on the right track.

    This is what worked. I need to change.

    var criteria = searcher.CreateQuery(IndexTypes.Content, BooleanOperation.And);
    

    to

    var criteria = searcher.CreateQuery(IndexTypes.Content, BooleanOperation.Or);
    

    EG.

    var searcher = index.GetSearcher();
                    var criteria = searcher.CreateQuery(IndexTypes.Content, BooleanOperation.Or);
                    var examineQuery = criteria.NodeTypeAlias("contentPage").Or().NodeTypeAlias("blogDetailsPage").Or().NodeTypeAlias("eventDetailsPage").Or().NodeTypeAlias("officeDetailsPage").Or().NodeTypeAlias("sectorDetailsPage").Or().NodeTypeAlias("serviceDetailsPage").Or().NodeTypeAlias("staffDetailsPage");
    

    Hope this helps someone.

    Regards

    David

  • David Armitage 414 posts 1655 karma points
    Jul 23, 2020 @ 06:34
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies