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
Ah, found it. The SearchDataSource had a controlparameter for SearchQuery in markup, and even though the textbox from which it got it's value was empty I suppose it was interpreted as a freetext query. It works as expected now.
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?