Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
I'm trying to get the SearchDataSource to produce pages based on keywords that I have tagged the pages with. Not free-text, just in a certain keywords property. The number of keywords required (i want a logical AND between keywords) may vary, so I try to add them from codebehind. I get no results even though I should. If I use FindPagesWithCriteria instead, I get the expected results. The SearchQuery of the SearchDataSource is empty, which means it should execute a FindPagesWithCriteria, right? What am I doing wrong?
string[] keywords = new string[] { "hund", "katt" }; PropertyCriteriaCollection coll = new PropertyCriteriaCollection(); foreach (string keyword in keywords) { PropertyCriteria categoryCriterion = new PropertyCriteria(); categoryCriterion.Name = "Keywords"; categoryCriterion.Type = PropertyDataType.LongString; categoryCriterion.Value = keyword; categoryCriterion.Condition = CompareCondition.Contained; categoryCriterion.Required = true; PropertyCriteriaControl criterionControl = new PropertyCriteriaControl(categoryCriterion); coll.Add(categoryCriterion); SearchDataSource.Criteria.Add(criterionControl); } PageDataCollection pages = DataFactory.Instance.FindPagesWithCriteria(PageReference.RootPage, coll); // Gets 1 result (as expected) SearchDataSource.DataBind(); // Gets no results