Copied to clipboard

Flag this post as spam?

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


  • andrew shearer 510 posts 659 karma points
    Jan 12, 2023 @ 06:49
    andrew shearer
    0

    examine searching in umbraco 10+

    hello

    I thought my search requirement was straight forward but I’m struggling to work out the required chained query syntax to achieve it. Simply put I would like to find anything that is doctype X, Y or Z, and either field ’a’ or field ‘b’ has the search term “q”.

    Code so far is:

                      _examineManager.TryGetSearcher("multisearchindex", out var cmsSearcher);
                  var cmsCriteria = cmsSearcher.CreateQuery(null, BooleanOperation.Or); 
                  var cmsQuery = cmsCriteria
                        .GroupedOr(new string[] { "__NodeTypeAlias" }, new string[] { "x", "y", "z" })
                        .And()
                        .Field("a", q)
                        .Or().Field("b", q)
    

    In my head the pseudo logic is: (doctype is z or y or z) and (field a is q or field b is q), but the results I’m getting suggest the above doesn’t do that. Any help would be appreciated, thanks!

    Ps "multisearchindex" is just my definition as per https://docs.umbraco.com/umbraco-cms/reference/searching/examine/pdfindex-multisearcher as results need to come from content and pdf media

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Jan 12, 2023 @ 09:25
    Huw Reddick
    0

    Not sure if it will help/work, but you could try changing

    .And()
    .Field("a", q)
     .Or().Field("b", q)
    

    to another GroupedOr

    .And().GroupedOr(new[]{"a","b"},q)
    
  • andrew shearer 510 posts 659 karma points
    Jan 16, 2023 @ 19:30
    andrew shearer
    0

    thanks Huw, yes i had considered that idea too. Ultimately i want more than one conditional OR clause in a addition to what would be the mandatory doctype alias clause. Trying to work out the correct chained syntax eludes me 0_0

Please Sign in or register to post replies

Write your reply to:

Draft