Example #1
0
 private void ReadFieldsDict(Dictionary<string, object> fieldsDict, MatchQueryBase matchQuery)
 {
     matchQuery.Analyzer = fieldsDict.GetStringOrDefault(_ANALYZER);
     matchQuery.CutOffFrequency = fieldsDict.GetDouble(_CUTOFF_FREQUENCY, _CUTOFF_FREQUENCY_DEFAULT);
     matchQuery.Fuzziness = fieldsDict.GetDouble(_FUZZINESS, _FUZZINESS_DEFAULT);
     matchQuery.IsLenient = fieldsDict.GetBool(_LENIENT, _LENIENT_DEFAULT);
     matchQuery.MaximumExpansions = fieldsDict.GetInt32OrNull(_MAX_EXPANSIONS);
     matchQuery.MinimumShouldMatch = fieldsDict.GetInt32(_MINIMUM_SHOULD_MATCH, _MINIMUM_SHOULD_MATCH_DEFAULT);
     matchQuery.Operator = OperatorEnum.Find(fieldsDict.GetString(_OPERATOR, _OPERATOR_DEFAULT.ToString()));
     matchQuery.PrefixLength = fieldsDict.GetInt32(_PREFIX_LENGTH, _PREFIX_LENGTH_DEFAULT);
     matchQuery.RewriteMethod = RewriteMethodsEnum.Find(fieldsDict.GetString(_REWRITE, "not a real object"));
     matchQuery.ZeroTerm = ZeroTermsEnum.Find(fieldsDict.GetString(_ZERO_TERMS_QUERY, _ZERO_TERMS_QUERY_DEFAULT.ToString()));
     matchQuery.QueryName = fieldsDict.GetStringOrDefault(QuerySerializer._QUERY_NAME);
 }
Example #2
0
        private Dictionary<string, object> CreateFieldsDict(MatchQueryBase query)
        {
            Dictionary<string, object> fieldsDict = new Dictionary<string, object>();

            fieldsDict.AddObject(_ANALYZER, query.Analyzer);
            fieldsDict.AddObject(_CUTOFF_FREQUENCY, query.CutOffFrequency, _CUTOFF_FREQUENCY_DEFAULT);
            fieldsDict.AddObject(_FUZZINESS, query.Fuzziness, _FUZZINESS_DEFAULT);
            fieldsDict.AddObject(_MAX_EXPANSIONS, query.MaximumExpansions);
            fieldsDict.AddObject(_REWRITE, query.RewriteMethod == null ? null : query.RewriteMethod.ToString(), null);
            fieldsDict.AddObject(_LENIENT, query.IsLenient, _LENIENT_DEFAULT);
            fieldsDict.AddObject(_MINIMUM_SHOULD_MATCH, query.MinimumShouldMatch, _MINIMUM_SHOULD_MATCH_DEFAULT);
            fieldsDict.AddObject(_OPERATOR, query.Operator.ToString(), _OPERATOR_DEFAULT.ToString());
            fieldsDict.AddObject(_PREFIX_LENGTH, query.PrefixLength, _PREFIX_LENGTH_DEFAULT);
            fieldsDict.AddObject(_ZERO_TERMS_QUERY, query.ZeroTerm.ToString(), _ZERO_TERMS_QUERY_DEFAULT.ToString());
            fieldsDict.AddObject(QuerySerializer._QUERY_NAME, query.QueryName);
            return fieldsDict;
        }