Copied to clipboard

Flag this post as spam?

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


  • Thomas 315 posts 602 karma points c-trib
    Nov 13, 2020 @ 13:40
    Thomas
    0

    Hey I'm trying to make a raw query string for my search.

    I would like to only allow nodes with specific alias

    I have tried with this.

    var nodeAlias = new List<string>() { "articlePage", "sectionPage" };
                var allowedContentTypes = string.Join(" ", nodeAlias.Select(x => $"{x}"));
                if (allowedContentTypes.Any()) query.Append($" AND +(__NodeTypeAlias:{string.Join(" ", allowedContentTypes)})");
    

    That gives me this AND +(__NodeTypeAlias:articlePage sectionPage File)

    It only looks at the first alias..

    How do I add more then one alias?

    Thanks :)

  • Thomas 315 posts 602 karma points c-trib
    Nov 13, 2020 @ 14:03
    Thomas
    100

    Got it to work :)

    var nodeAlias = new List<string>() { "articlePage", "sectionPage", "File" };
                var allowedContentTypes = string.Join(" OR ", nodeAlias.Select(x => $"__NodeTypeAlias:{x}"));
                if (allowedContentTypes.Any()) query.Append($" AND (+({allowedContentTypes}))");
    
Please Sign in or register to post replies

Write your reply to:

Draft