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);
 }
        internal static void Deserialize(DocumentPropertyBase prop, Dictionary<string, object> fieldDict)
        {
            if (!fieldDict.Any())
                return;

            MappingBase.Deserialize(prop, fieldDict);
            prop.IncludeInAll = fieldDict.GetBool(_INCLUDE_IN_ALL, _INCLUDE_IN_ALL_DEFAULT);
            prop.IndexName = fieldDict.GetStringOrDefault(_INDEX_NAME);
            prop.PropertyType = PropertyTypeEnum.Find(fieldDict.GetString(_TYPE, _PROPERTY_TYPE_DEFAULT.ToString()));
        }
Example #3
0
        internal static void Deserialize(MappingBase mappingBase, Dictionary<string, object> fieldDict)
        {
            if (fieldDict == null || !fieldDict.Any())
                return;

            IndexSettingEnum indexSetting = IndexSettingEnum.No;
            mappingBase.Index = IndexSettingEnum.Find(fieldDict.GetString(_INDEX_KEY, mappingBase._INDEX_DEFAULT.ToString()));

            StoreSettingEnum storeSetting = StoreSettingEnum.No;
            mappingBase.Store = fieldDict.GetBool(_STORE_KEY, mappingBase._STORE_DEFAULT);
        }
Example #4
0
        internal static void Deserialize(ObjectProperty prop, Dictionary<string, object> fieldDict)
        {
            if (fieldDict == null || !fieldDict.Any())
                return;

            if (fieldDict.ContainsKey(_COPY_TO))
            {
                try
                {
                    prop.CopyTo = JsonConvert.DeserializeObject<IEnumerable<string>>(fieldDict.GetString(_COPY_TO));
                }
                catch
                {
                    prop.CopyTo = new List<string>() { fieldDict.GetString(_COPY_TO) };
                }
            }

            prop.Dynamic = DynamicSettingEnum.Find(fieldDict.GetString(_DYNAMIC, _DYNAMIC_DEFAULT.ToString()));
            prop.IncludeInAll = fieldDict.GetBool(_INCLUDE_IN_ALL, _INCLUDE_IN_ALL_DEFAULT);
            prop.IsEnabled = fieldDict.GetBool(_IS_ENABLED, _IS_ENABLED_DEFAULT);

            if (fieldDict.ContainsKey(_PROPERTIES))
            {
                prop.Properties = JsonConvert.DeserializeObject<DocumentPropertyCollection>(fieldDict.GetString(_PROPERTIES));
            }
        }
Example #5
0
 internal static void DeserializeBaseValues(IFilter filter, bool cacheDefault, Dictionary<string, object> fieldDict)
 {
     filter.Cache = fieldDict.GetBool(_CACHE, cacheDefault);
     filter.CacheKey = fieldDict.GetStringOrDefault(_CACHE_KEY);
     filter.FilterName = fieldDict.GetStringOrDefault(_FILTER_NAME);
 }
Example #6
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 #7
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);
 }
Example #8
0
        internal static void Deserialize(FieldProperty field, Dictionary<string, object> fieldDict)
        {
            MappingBase.Deserialize(field, fieldDict);
            field.IncludeInAll = fieldDict.GetBool(_INCLUDE_IN_ALL, _INCLUDE_IN_ALL_DEFAULT);
            field.Boost = fieldDict.GetDouble(_BOOST, _BOOST_DEFAULT);

            if (fieldDict.ContainsKey(_COPY_TO))
            {
                try 
                {
                    field.CopyTo = JsonConvert.DeserializeObject<IEnumerable<string>>(fieldDict.GetString(_COPY_TO));
                }
                catch
                {
                    field.CopyTo = new List<string>(){ fieldDict.GetString(_COPY_TO) };
                }
            }

            field.DocValuesFormat = DocValuesFormatEnum.Find(fieldDict.GetString(_DOC_VALUES_FORMAT, _DOC_VALUES_FORMAT_DEFAULT.ToString()));

            if(fieldDict.ContainsKey(_FIELD_DATA))
            {
                field.FieldData = FieldDataFilter.Deserialize(JsonConvert.DeserializeObject<Dictionary<string, object>>(fieldDict.GetString(_FIELD_DATA)));
            }
            
            if(fieldDict.ContainsKey(_FIELDS))
            {
                field.Fields = JsonConvert.DeserializeObject<DocumentPropertyCollection>(fieldDict.GetString(_FIELDS));
            }

            field.IndexName = fieldDict.GetString(_INDEX_NAME, field.Name);
            if(fieldDict.ContainsKey(_NULL_VALUE))
                field.NullValue = fieldDict[_NULL_VALUE];

            field.PostingsFormat = PostingFormatEnum.Find(fieldDict.GetString(_POSTINGS_FORMAT, _POSTINGS_FORMAT_DEFAULT.ToString()));
            field.Similarity = SimilarityAlgorithmEnum.Find(fieldDict.GetString(_SIMILARITY, _SIMILARITY_DEFAULT.ToString()));
        }
        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()));
        }