Try our conversational search powered by Generative AI!

PropertyCriteria always required in search

Vote:
 
Hi Im running a episerver 4.41 system and we got a problem with the search page. On the search page we added a number of selection boxes that the customer can add criterias on, these are not required but should be treated as "or". Even if I set the required option to false it still treats all criterias with "and". Is this a bug or am I doing somthing totally wrong? Best regards Jonas for (int i = 0; i < Request.Params.Count; i++) { string key = Request.Params.GetKey(i); if (key.IndexOf("xxx") > -1 || key.IndexOf("yyy") > -1) { PropertyCriteria criteria = new PropertyCriteria(); criteria.Condition = CompareCondition.Equal; criteria.Type = PropertyDataType.Category; criteria.Name = "PageCategory"; criteria.Value = Request.Params.GetValues(i)[0]; criteria.Required = false; changeSearch.Visible=true; advSearch.Visible=false; SearchResults.Criterias.Add(criteria); } }
#17372
Apr 27, 2005 9:30
Vote:
 
To OR category IDs, just create a string with comma-separated values. For example: ArrayList categories = new ArrayList(); for (int i = 0; i < Request.Params.Count; i++) { string key = Request.Params.GetKey(i); if (key.IndexOf("xxx") > -1 || key.IndexOf("yyy") > -1) { categories.Add(Request.Params.GetValues(i)[0]); } } PropertyCriteria criteria = new PropertyCriteria(); criteria.Value = String.Join(',', (string[]) categories.ToArray(typeof(string))); // etc.
#18078
May 19, 2005 13:43
Vote:
 
Thanks! That was exactly was I was looking for as well. It would be of great help if hints like this was found in the SDK...
#18079
Aug 17, 2005 16:22
Vote:
 
Thanks! That was exactly was I was looking for as well. It would be of great help if hints like this was found in the SDK help doc...
#18080
Aug 17, 2005 16:25
Vote:
 
We try to add more info to the SDK continuously. If there is some specific topic that you feel is lacking information, just let us know. By the way, I have added a hint about categories in propertysearch to the SDK.
#18081
Aug 18, 2005 15:14
Vote:
 
I have two more questions: 1) I can't get what you just said to work, actually. I want to find all pages with a certain property equal to either of a few values. My code: PropertyCriteria crit = new PropertyCriteria(); crit.Type = PropertyDataType.String; crit.Required = false; //tried true as well crit.Condition = CompareCondition.Equal; crit.Name = "SubjectCode"; crit.Value = "H,HA,HC"; Does the comma-separated string as a value only work for categories? How do I do this then? Note: I have other criterias as well. 2) Is there a way of getting page hits regardless of capitalization (PropertySearch)? E.g. user enters "hello world" and I want to find the page with property value "Hello world"? 3) Is it possible to create my own CompareConditions? A yes here would answer question #2 as well
#18082
Aug 19, 2005 16:28
Vote:
 
1) The "ORing" technique I showed does only work with categories, there is no equivalent way to search strings. Instead, you can create a custom filter to find exactly the pages you want. See the following FAQ-article for examples: http://www.episerver.com/templates/faq____928.aspx 2) The results of propertysearches on strings depend on the database collation. So if you have a database with case-sensitive strings, the propertysearches will be case-sensitive. There is no way to force the propertysearch to be case-insensitive (at least yet), but you can use custom filters to get the same results. 3) Custom compare conditions are not supported in the API, but you can use filters instead.
#18083
Aug 22, 2005 10:58
* 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.