Sitecore Asked by PSS on November 30, 2020
I am working with a custom SXA search query token. I want to Insert
with two different values.
foreach (var val in values)
{
args.Models.Insert(i, this.BuildModel(itemFieldName, val));
}
args.Models.Remove(model);
SearchStringModel:
protected virtual SearchStringModel BuildModel(string fieldName, string value)
{
var name = fieldName;
return new SearchStringModel("custom", FormattableString.Invariant(FormattableStringFactory.Create("{0}|{1}", name, value)))
{
Operation = "must"
};
}
But this logic is not showing search results. Is there any way to achieve this functionality?
The AND or OR operators in between the parts of your query are placed based on the Operation
as set in the SearchStringModel
.
In your case, the Operation is set to "must" - which is an AND. If you want an OR, you can use "should" here:
protected virtual SearchStringModel BuildModel(string fieldName, string value)
{
var name = fieldName;
return new SearchStringModel("custom", FormattableString.Invariant(FormattableStringFactory.Create("{0}|{1}", name, value)))
{
Operation = "should"
};
}
Answered by Gatogordo on November 30, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP