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!
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
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:
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
Not sure if it will help/work, but you could try changing
to another GroupedOr
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
is working on a reply...