static void WritePropertiesFromAttribute(this StringBuilder _jsonWriter, ElasticsearchPropertyAttribute att, string _propertyName, string _type) { if (att.AddSortField) { _jsonWriter.WritePropertyName("type"); _jsonWriter.WriteValue("multi_field"); _jsonWriter.WritePropertyName("fields"); _jsonWriter.WriteStartObject(); _jsonWriter.WritePropertyName(_propertyName); _jsonWriter.WriteStartObject(); } if (att.NumericType != NumberType.Default) { _jsonWriter.WritePropertyName("type"); var numericType = att.NumericType.GetStringValue(); _jsonWriter.WriteValue(numericType.ToLowerInvariant()); } else { _jsonWriter.WritePropertyName("type"); _jsonWriter.WriteValue(_type); } if (!att.Analyzer.IsNullOrEmpty()) { _jsonWriter.WritePropertyName("analyzer"); _jsonWriter.WriteValue(att.Analyzer); } if (!att.IndexAnalyzer.IsNullOrEmpty()) { _jsonWriter.WritePropertyName("index_analyzer"); _jsonWriter.WriteValue(att.IndexAnalyzer); } if (!att.IndexAnalyzer.IsNullOrEmpty()) { _jsonWriter.WritePropertyName("index_analyzer"); _jsonWriter.WriteValue(att.IndexAnalyzer); } if (!att.NullValue.IsNullOrEmpty()) { _jsonWriter.WritePropertyName("null_value"); _jsonWriter.WriteValue(att.NullValue); } if (!att.SearchAnalyzer.IsNullOrEmpty()) { _jsonWriter.WritePropertyName("search_analyzer"); _jsonWriter.WriteValue(att.SearchAnalyzer); } if (!att.DateFormat.IsNullOrEmpty()) { _jsonWriter.WritePropertyName("format"); _jsonWriter.WriteValue(att.DateFormat); } if (att.Index != FieldIndexOption.Analyzed) { _jsonWriter.WritePropertyName("index"); _jsonWriter.WriteValue(att.Index.GetStringValue()); } if (att.TermVector != TermVectorOption.No) { _jsonWriter.WritePropertyName("term_vector"); _jsonWriter.WriteValue(att.TermVector.GetStringValue()); } if (att.OmitNorms) { _jsonWriter.WritePropertyName("omit_norms"); _jsonWriter.WriteValue("true"); } if (att.DocValues) { _jsonWriter.WritePropertyName("doc_values"); _jsonWriter.WriteValue("true"); } if (att.OmitTermFrequencyAndPositions) { _jsonWriter.WritePropertyName("omit_term_freq_and_positions"); _jsonWriter.WriteValue("true"); } if (!att.IncludeInAll) { _jsonWriter.WritePropertyName("include_in_all"); _jsonWriter.WriteValue("false"); } if (att.Store) { _jsonWriter.WritePropertyName("store"); _jsonWriter.WriteValue("true"); } if (Math.Abs(att.Boost - 1) > Double.Epsilon) { _jsonWriter.WritePropertyName("boost"); _jsonWriter.WriteRawValue(att.Boost.ToString(CultureInfo.InvariantCulture)); } if (att.PrecisionStep != 4) { _jsonWriter.WritePropertyName("precision_step"); _jsonWriter.WriteRawValue(att.PrecisionStep.ToString(CultureInfo.InvariantCulture)); } if (!att.Similarity.IsNullOrEmpty()) { _jsonWriter.WritePropertyName("similarity"); _jsonWriter.WriteValue(att.Similarity); } if (att.AddSortField) { _jsonWriter.WriteEndObject(); _jsonWriter.WritePropertyName("sort"); _jsonWriter.WriteStartObject(); if (att.NumericType != NumberType.Default) { _jsonWriter.WritePropertyName("type"); string numericType = att.NumericType.GetStringValue(); _jsonWriter.WriteValue(numericType.ToLowerInvariant()); } else { _jsonWriter.WritePropertyName("type"); _jsonWriter.WriteValue(_type); } if (att.SortAnalyzer.IsNullOrEmpty()) { _jsonWriter.WritePropertyName("index"); _jsonWriter.WriteValue(FieldIndexOption.NotAnalyzed.GetStringValue()); } else { _jsonWriter.WritePropertyName("index_analyzer"); _jsonWriter.WriteValue(att.SortAnalyzer); } _jsonWriter.WriteEndObject(); _jsonWriter.WriteEndObject(); } }