Example #1
0
 internal static void DeserializeFacetInfo(FacetBase facet, Dictionary<string, object> facetDict)
 {
     if (facetDict.ContainsKey(_FACET_FILTER))
         facet.FacetFilter = JsonConvert.DeserializeObject<IFilter>(facetDict.GetString(_FACET_FILTER));
     facet.IsScopeGlobal = facetDict.GetBool(_GLOBAL, _GLOBAL_DEFAULT);
     facet.NestedObject = facetDict.GetStringOrDefault(_NESTED);
     facet.Size = facetDict.GetInt32(_SIZE, _SIZE_DEFAULT);
 }
Example #2
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 #3
0
 internal static void DeserializeNumber(NumberProperty number, Dictionary<string, object> fieldDict)
 {
     FieldProperty.Deserialize(number, fieldDict);
     number.PrecisionStep = fieldDict.GetInt32(_PRECISION_STEP, _PRECISION_STEP_DEFAULT);
     number.DocValues = fieldDict.GetBool(_DOC_VALUES, _DOC_VALUES_DEFAULT);
     number.IgnoreMalformed = fieldDict.GetBool(_IGNORE_MALFORMED, _IGNORE_MALFORMED_DEFAULT);
     number.Coerce = fieldDict.GetBool(_COERCE, _COERCE_DEFAULT);
 }
        internal static void DeserializeHighlighterOptions(HighlighterOptions options, Dictionary<string, object> fieldDict)
        {
            if(fieldDict == null || !fieldDict.Any())
                return;

            options.BoundaryCharacters = fieldDict.GetString(_BOUNDARY_CHARACTERS, _BOUNDARY_CHARACTERS_DEFAULT);
            options.BoundaryMaximumScan = fieldDict.GetInt32(_BOUNDARY_MAXIMUM_SCAN, _BOUNDARY_MAXIMUM_SCAN_DEFAULT);
            options.Encoder = EncoderTypeEnum.Find(fieldDict.GetString(_ENCODER, _ENCODER_DEFAULT.ToString()));
            options.FragmentSize = fieldDict.GetInt32(_FRAGMENT_SIZE, _FRAGMENT_SIZE_DEFAULT);
            options.NoMatchSize = fieldDict.GetInt32(_NO_MATCH_SIZE, _NO_MATCH_SIZE_DEFAULT);
            options.NumberOfFragments = fieldDict.GetInt32(_NUMBER_OF_FRAGMENTS, _NUMBER_OF_FRAGMENTS_DEFAULT);
            options.PhraseLimit = fieldDict.GetInt32(_PHRASE_LIMIT, _PHRASE_LIMIT_DEFAULT);
            if(fieldDict.ContainsKey(_POST_TAGS))
                options.PostTags = JsonConvert.DeserializeObject<IEnumerable<string>>(fieldDict.GetString(_POST_TAGS));
            if(fieldDict.ContainsKey(_PRE_TAGS))
                options.PreTags = JsonConvert.DeserializeObject<IEnumerable<string>>(fieldDict.GetString(_PRE_TAGS));
            options.RequireFieldMatch = fieldDict.GetBool(_REQUIRE_FIELD_MATCH, _REQUIRE_FIELD_MATCH_DEFAULT);
            options.TagsSchema = TagsSchemaEnum.Find(fieldDict.GetString(_TAGS_SCHEMA, _TAGS_SCHEMA_DEFAULT.ToString()));
            options.Type = HighlighterTypeEnum.Find(fieldDict.GetString(_HIGHLIGHTER_TYPE, _HIGHLIGHTER_TYPE_DEFAULT.ToString()));
        }
Example #5
0
        private FuzzyQueryBase BuildFuzzyQuery(string fieldName, Dictionary<string, object> fieldDict)
        {
            object value = fieldDict[_VALUE];
            object fuzziness = null;
            if (fieldDict.ContainsKey(_FUZZINESS))
                fuzziness = fieldDict[_FUZZINESS];

            FuzzyQueryBase query = null;
            if (IsDateTime(value))
            {
                if(fuzziness != null)
                    query = new FuzzyDateQuery(fieldName, DateTime.Parse(value.ToString()), new TimeValue(fuzziness.ToString()).TimeSpan);
                else
                    query = new FuzzyDateQuery(fieldName, DateTime.Parse(value.ToString()));
            }
            else if (IsNumeric(value))
            {
                bool isInteger = false;
                if (value is Int64 || value is Int32)
                    isInteger = true;

                if (fuzziness != null && isInteger)
                {
                    if (isInteger)
                        query = new FuzzyNumberQuery(fieldName, (Int64)value, (Int64)fuzziness);
                    else
                        query = new FuzzyNumberQuery(fieldName, (Double)value, (Double)fuzziness);
                }
                else
                {
                    if (isInteger)
                        query = new FuzzyNumberQuery(fieldName, (Int64)value);
                    else
                        query = new FuzzyNumberQuery(fieldName, (Double)value);
                }
            }
            else
            {
                if (fuzziness != null)
                    query = new FuzzyStringQuery(fieldName, value.ToString(), Int32.Parse(fuzziness.ToString()));
                else
                    query = new FuzzyStringQuery(fieldName, value.ToString());
            }

            query.Boost = fieldDict.GetDouble(QuerySerializer._BOOST, QuerySerializer._BOOST_DEFAULT);
            query.MaximumExpansions = fieldDict.GetInt32(_MAXIMUM_EXPANSIONS, _MAXIMUM_EXPANSIONS_DEFAULT);
            query.PrefixLength = fieldDict.GetInt32(_PREFIX_LENGTH, _PREFIX_LENGTH_DEFAULT);
            query.QueryName = fieldDict.GetStringOrDefault(QuerySerializer._QUERY_NAME);
            return query;
        }