private double EvaluateFieldRules(string queryString, string compareString, SearchRuleType searchType) { double comparison = 0.0; //check to see if one or both are null: if (String.IsNullOrEmpty(queryString)) { //if both are null, they actually match, but we want to lower the confidence slightly to prevent resolution if (String.IsNullOrEmpty(compareString)) { comparison = 0.99; } //if only one is null, we don't really have a basis for comparison (additional or missing information) else { comparison = 0.5; } } // Exact comparison. else if (((searchType & SearchRuleType.Exact) == SearchRuleType.Exact) && queryString.Equals(compareString, StringComparison.InvariantCultureIgnoreCase)) { comparison = 1.0; } // First Letter comparison. else if (((searchType & SearchRuleType.FirstLetter) == SearchRuleType.FirstLetter) && (Char.ToUpper(queryString[0]) == Char.ToUpper(compareString[0]))) { comparison = 1.0; } // Contains comparison. else if (((searchType & SearchRuleType.Contains) == SearchRuleType.Contains) && compareString.IndexOf(queryString, StringComparison.OrdinalIgnoreCase) >= 0) { comparison = 1.0; } // Fuzzy comparison. else if ((searchType & SearchRuleType.Fuzzy) == SearchRuleType.Fuzzy) { comparison = _comparer.Compare(queryString, compareString); } // Starts-with comparison. else if (((searchType & SearchRuleType.StartsWith) == SearchRuleType.StartsWith) && compareString.StartsWith(queryString, StringComparison.OrdinalIgnoreCase)) { comparison = 1.0; } return(comparison); }
private void m_addCriteriaButton_Click(object sender, EventArgs e) { //get a local reference of the currently selected PropertyDefinition object PropDefItem propertyItem = m_propertyComboBox.SelectedItem as PropDefItem; PropDef property; property = (propertyItem == null) ? null : propertyItem.PropDef; //get local reference of the condition combo boxes currently selected item Condition condition = m_conditionComboBox.SelectedItem as Condition; if (property == null || condition == null) { return; } SearchRuleType rule = SearchRuleType.Must; RuleItem ruleItem = m_ruleComboBox.SelectedItem as RuleItem; if (ruleItem != null) { rule = ruleItem.Rule; } //create a SearchCondition object SrchCond searchCondition = new SrchCond(); searchCondition.PropDefId = property.Id; searchCondition.PropTyp = PropertySearchType.SingleProperty; searchCondition.SrchOper = condition.Code; if (checkBox1.Checked) { //here we would effectively need to perform a search for everything and then search those results. searchCondition.SrchTxt = m_valueComboBox.SelectedItem.ToString(); } else { searchCondition.SrchTxt = m_valueTextBox.Text; } searchCondition.SrchRule = rule; //create the list item to contain the condition SrchCondItem searchItem = new SrchCondItem(searchCondition, property); //add the SearchCondition object to the search criteria list box m_criteriaListBox.Items.Add(searchItem); }
public MasterIndexSearchAttribute( bool searchable, string columnName = "", SearchRuleType searchType = SearchRuleType.None, double fieldWeight = 1.0, bool required = false, SearchRulePriority[] priorities = null) { Searchable = searchable; RmsClassicColumnName = columnName; SearchType = searchType; FieldWeight = fieldWeight; Required = required; Priorities = priorities ?? new [] { SearchRulePriority.Priority1 }; }
public RuleItem(SearchRuleType rule, string displayName) { this.Rule = rule; this.DisplayName = displayName; }