static LatLng FromDictionary(Dictionary <string, object> dic) { var lat = dic.GetDouble("lat"); var lng = dic.GetDouble("lng"); return(new LatLng(lat, lng)); }
internal static Frequency Deserialize(Dictionary<string, object> fieldDict) { if (fieldDict == null || !fieldDict.Any()) return null; if (fieldDict.ContainsKey(_MINIMUM_SEGMENT_SIZE)) { return new Frequency(fieldDict.GetDouble(_MINIMUM), fieldDict.GetDouble(_MAXIMUM), fieldDict.GetInt64(_MINIMUM_SEGMENT_SIZE)); } return new Frequency(fieldDict.GetDouble(_MINIMUM), fieldDict.GetDouble(_MAXIMUM)); }
public static float GetFloat(this Dictionary <string, object> dic, string key) { return((float)dic.GetDouble(key)); }
// "prop1":{ "top": lat, "left":lon, "bottom": lat, "right": lon } - vertices private GeoBoundingBoxFilter GetBoxFromVertices(string fieldName, Dictionary<string, object> boxDict) { CoordinatePoint topLeft = new CoordinatePoint(boxDict.GetDouble(_TOP), boxDict.GetDouble(_LEFT)); CoordinatePoint bottomRight = new CoordinatePoint(boxDict.GetDouble(_BOTTOM), boxDict.GetDouble(_RIGHT)); return new GeoBoundingBoxFilter(fieldName, topLeft, bottomRight); }
private DistanceRangeBucket DeserializeRangeBucket(Dictionary<string, object> bucketDict) { DistanceRangeBucket bucket = new DistanceRangeBucket(); if (bucketDict.ContainsKey(_TO)) bucket.To = bucketDict.GetDouble(_TO); if (bucketDict.ContainsKey(_FROM)) bucket.From = bucketDict.GetDouble(_FROM); return bucket; }
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); }
private static CoordinatePoint GetPointFromDictionary(Dictionary<string, object> pointDict) { return new CoordinatePoint(pointDict.GetDouble(_LATITUDE), pointDict.GetDouble(_LONGITUDE)); }
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())); }
/// <summary> /// /// </summary> /// <param name="dic"></param> /// <param name="key"></param> /// <param name="defaultValue"></param> /// <returns></returns> public static float GetFloat(this Dictionary <string, object> dic, string key, double defaultValue = 0) { return((float)dic.GetDouble(key, defaultValue)); }
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; }