Copied to clipboard

Flag this post as spam?

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


  • skiltz 501 posts 701 karma points
    May 05, 2020 @ 05:20
    skiltz
    0

    Examime + Umbraco 7 Only Search single Node Type

    Umbraco 7.

    Current query looks like this.

    var searchQuery = searchCriteria.Field("nodeName", query).Or().Field("bodyText", query).And().OrderByDescending("createDate");

    which works fine but searches all node types. I want it to only search supportDoc doc type.

    If I use this. still doesn't seem to work.

    var searchQuery = searchCriteria.Field("nodeName", query).Or().Field("bodyText", query).And().Field("nodeTypeAlias", "supportDoc").And().OrderByDescending("createDate");

  • Yakov Lebski 591 posts 2346 karma points
    May 05, 2020 @ 16:19
    Yakov Lebski
    0

    you can use

    searchCriteria.NodeTypeAlias("supportDoc")
    

    you query will be

    var searchQuery = searchCriteria.Field("nodeName", query).Or().Field("bodyText", query).And().NodeTypeAlias("supportDoc").And().OrderByDescending("createDate");
    
Please Sign in or register to post replies

Write your reply to:

Draft