Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

SearchDatasource vs. FindPagesWithCriteria

Vote:
 

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
#29395
Apr 24, 2009 12:47
Vote:
 
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.
#29396
Apr 24, 2009 13:02
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.