If you do a combined freetext (indexed) search and property search using a SearchDataSource, the property criteria will be used as a post-filter (i.e. the query will not run in the DBMS as with FindPagesWithCriteria, the first step (free text index search) will however of course be handled by the DBMS). If you already have a PropertyCriteriaCollection I'm sure there's a way to add it to the SearchDataSource from codebehind. I know you should be able to loop through your PropertyCriteriaCollection and create a PropertyCriteriaControl for each PropertyCriteria, I think there's a constructor accepting the PropertyCriteria. Not super-elegant, but working.
Thanks for your reply I could extract each PropertyCriteria from the Collection and add them to the Control and it works fine
var search = new SearchDataSource { SearchFiles = false };
search.PageTypeID = SearchPageTypeID;
search.LanguageBranches = GetSearchLocales();
search.IncludeRootPage = false;
search.PageLink = rootPage;
search.SearchQuery = searchPhrase;
PropertyCriteriaControl prpCriteriaControl;
foreach (PropertyCriteria prpCriteria in prpCriteriaCollection)
{
prpCriteriaControl = new PropertyCriteriaControl(prpCriteria);
search.Criteria.Add(prpCriteriaControl);
}
I want to search on a free text field within a certain filtered criteria.
I already have code which filters content using FindPagesWithCriteria() and a PropertyCriteriaCollection for filtering by date and category against a parent PageReference. I also have code which uses SearchDataSource() to perform a free text search against a parent PageReference.
Essentially I want to combine the functionality of these two searches. e.g. I want to search for the word 'green' in category = A.
I see it is possible to manually filter a List<PageData> if listPages and remove the ones you don't want i.e.
But is there a more elegant way where I can reuse the PropertyCriteriaCollection I have already created and apply it to my SearchDataSource() results?
Thanks